[postgis-users] geos based spatial queries

strk strk at keybit.net
Thu Nov 20 13:34:50 PST 2003


dblasby wrote:
> Peter Aberline wrote:
> 
> > select count(*)
> > from points
> > where within(points.the_geom, (select the_geom from states where
> > state_name = 'BigState')) = true;
> 
> try:
> 
> SELECT count(*) FROM points WHERE
>   within(points.the_geom, (select the_geom from states   where 
> state_name = 'BigState')  AND
> points.the_geom && (select the_geom from states   where  state_name = 
> 'BigState')

I'd try:

SELECT count(*) FROM points p, states s
	WHERE s.state_name = 'BigState' -- a btree here
	AND p.the_geom && s.the_geom -- a GiST here
	AND within(p.the_geom, s.the_geom); -- is really needed ?

--strk;



More information about the postgis-users mailing list