Hallo

What you are doing with ST_Dwithin is to check if your geom and geometry have 
parts closer to (or exactly) 0.00001 mapunits from eachother. If you are using 
a meter based SRID then you are checking if they are within 0.00001 meters from 
eachother. So actually in this case your points can be just outside the polygon 
and returning true. If you want to use st_dwithin you should use 0 instead of 
0.00001 . But I don't think that is any faster than ST_Intersects. The 
important thing in both cases is to have working spatial indexes. 

put an index on geom column in my_neighbour table and analyze the table.

Create index idx_mn_geom 
on my_neighbour
using gist(geom);
analyse my_neighbour;

Then try:
SELECT id, geom
FROM my_neighbour
WHERE ST_Intersects (geom, geometry);

I guess that is the best solution.

Hope that helps

Nicklas

2010-05-25 nguyen liem  wrote:

Hi all
>
>At the first time i used ST_Contains but it take a long time, so I used 
>ST_Dwithin to improve the performance for the query statement but i don't know 
>it is correct or not.
>I would like to know my points are within in polygon or not:
>
>SELECT id, geom
>FROM my_neighbour
>WHERE ST_Dwithin (geom, geometry, 0.00001)
>
>geometry: is a polygon(input parameter).
>0.00001: I means the radius of geometry is 1 meters, is it right?
>
>
>Cheers.
>
>-- 
>Liem Nguyen
>Developer
>Axon Active Corp.
>----------------------------------------------------------------------------
>Direct Line      : +84 38 948 4645
>Fax                  : +84 38 811 3489
>Mobile Phone  : +84 168 994 8897
>Skype ID         : liemnguyendl2204
>Email               : liem.ngu...@axonactive.net / liemnguye...@gmail.com
>Web Site          : axonactive.vn
>Address           : 87 Thang Long Street,Gate 2 Ward 4,
>                          Tan Binh District, HCM city, Vietnam.
>
>
_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to