[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    Re: [postgis-users] postgis and mapserver - queries
From:       David Blasby <dblasby () refractions ! net>
Date:       2003-06-13 21:31:44
Message-ID: 3EEA42C0.9070708 () refractions ! net
[Download RAW message or body]

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic