[postgis-devel] ST_OrderingEquals vs ~=

Paragon Corporation lr at pcorp.us
Sun Jun 21 00:18:35 PDT 2009


 
Well technically you can't group by the box if you want a real geometry
back. But then if you have geometries sharing the same bbox -- you get hmm
one back.  I always thought it was done this way because if you needed to do
a DISTINCT or whatever where you have huge geometries -- it would be really
slow if it needed to consider the true uniqueness of each geometry.  

Example
SELECT COUNT(DISTINCT the_geom)
FROM (SELECT ST_GeomFromEWKT('LINESTRING (3 5, 3.4 4.5, 4 5)')
UNION ALL
SELECT ST_GeomFromText('POLYGON ((3 5, 3 4.5, 4 4.5, 3 5))')

) As foo(the_geom);

You hmm get an answer of 1.

SELECT the_geom
FROM (SELECT ST_GeomFromEWKT('LINESTRING (3 6, 3.4 4.5, 4 5)')
UNION ALL
SELECT ST_GeomFromText('POLYGON ((3 5, 3 4.5, 4 4.5, 3 5))')

) As foo(the_geom)
GROUP BY the_geom;
-- You get 1 record back. 


 I suppose any SQL purist would be flapping their hands in disgust  and
MySQLers would find this perfectly natural as you could do similar things
like this in MySQL  - have a group by that doesn't include all the fields in
your select output that are not aggregated and it would kindly arbitrarily
return one record which many consider a Feature of MySQL rather than a bug.






-----Original Message-----
From: postgis-devel-bounces at postgis.refractions.net
[mailto:postgis-devel-bounces at postgis.refractions.net] On Behalf Of Kevin
Neufeld
Sent: Sunday, June 21, 2009 12:57 AM
To: PostGIS Development Discussion
Subject: Re: [postgis-devel] ST_OrderingEquals vs ~=

Yeah, I hear you.  I was asked just the other day ... again ..."Why oh why
does = not mean = in PostGIS?  Is it for speed?  If so, that's what the &&
is for."  All I can do is smile and shrug my shoulders.  I really can't say
what the original reason behind it was.

It does kinda make sense that a GROUP BY geometry would use the exact
geometry.  If one was concerned about performance, they could explicitly
GROUP BY the bounding box of the geometry.

But you're right, who knows what's in that Pandora's box once you open it.

-- Kevin





More information about the postgis-devel mailing list