[postgis-users] postgis and mapserver - queries
David Blasby
dblasby at refractions.net
Fri Jun 13 14:31:44 PDT 2003
C F wrote:
> Basically it appears that PostgreSQL is smart enough to not to execute
> subqueries when it knows the outer expression will always be false.
> Here are some samples... notice in examples 3 & 4, the "never executed"
> statements.
I tried this out, and it works great - what a great idea! I'll put it
in the mappostgis.c (mapserver-PostGIS connector) next time I visit that
code.
This takes forever:
select * from (SELECT roads.the_geom AS the_geom, roads.oid AS oid,
min(distance(roads.the_geom, hospitals.the_geom)) AS dist FROM roads,
hospitals GROUP BY roads.oid, roads.the_geom) as foo limit 0;
this is real fast:
select * from (SELECT roads.the_geom AS the_geom, roads.oid AS oid,
min(distance(roads.the_geom, hospitals.the_geom)) AS dist FROM roads,
hospitals GROUP BY roads.oid, roads.the_geom) as foo where 0=1 limit 0;
dave
More information about the postgis-users
mailing list