~= — Returns
TRUE if A's bounding box is the same as B's.
~= operator returns
TRUE if the bounding box of geometry/geography A
is the same as the bounding box of geometry/geography B.
This operand will make use of any indexes that may be available on the geometries.
Availability: 1.5.0 changed behavior
This function supports Polyhedral surfaces.
This operator has changed behavior in PostGIS 1.5 from testing for actual geometric equality to only checking for bounding box equality. To complicate things it also depends on if you have done a hard or soft upgrade which behavior your database has. To find out which behavior your database has you can run the query below. To check for true equality use ST_OrderingEquals or ST_Equals and to check for bounding box equality =; operator is a safer option.
select 'LINESTRING(0 0, 1 1)'::geometry ~= 'LINESTRING(0 1, 1 0)'::geometry as equality; equality | -----------------+ t |
The above can be used to test if you have the new or old behavior of ~= operator.