[postgis-users] ST_Intersects Vs. ST_Intersection

Francois Hugues hugues.francois at irstea.fr
Sun Dec 2 12:17:46 PST 2012


Hello,

You should directly use st_intersects with st_intersection :
SELECT ST_Intersection(table1.geom, table2.geom)
>From table1, table2
Where st_intersects(table1.geom, table2.geom)

St_intersection is slower than st_intersects.

Did you think to build spatial (gist) index on your tables to improve performance ?

Hugues

 

--
Hugues FRANÇOIS
Ingénieur recherche

Irstea Grenoble
2 rue de la papeterie
38400 Saint-Martin d'Hères

tel : +33 (0)4.76.76.27.44
port : +33 (0)6.77.66.21.31
fax : +33 (0)4.76.51.38.03



 

________________________________

De : postgis-users-bounces at lists.osgeo.org [mailto:postgis-users-bounces at lists.osgeo.org] De la part de Ahmad Aburizaiza
Envoyé : dimanche 2 décembre 2012 17:44
À : PostGIS Users Discussion
Objet : [postgis-users] ST_Intersects Vs. ST_Intersection


Hello everyone, 

I have quick questions please about ST_Intersects Vs. ST_Intersection:


1.	Does the following SQL statement checks the intersection between each geom in table1 Vs. each geom in table2?
	SELECT ST_Intersection(table1.geom, table2.geom)
	From table1, table2;
	
2.	I have 300 lines in table1 and 600 lines in table2. ST_Intersects takes about 10 seconds to run while ST_Intersection takes more than 35 seconds. Isn't both check for intersections first which should take the long time needed? 
3.	I am trying to find the intersection points between lines in table1 and table2. What I am doing now is using ST_Intersects in PHP code to collect gids from both tables of the lines that intersects and than ST_Intersections on the gids found from both tables. If someone nows a better solution, can you please advise? 


Thank you all,
---------------------------------------------------------------------------
Ahmad Aburizaiza
PhD student at George Mason University
Geography and Geoinformation Science Department
Fairfax, VA, USA
Tel : +1-703-981-0354 <tel:%2B1-703-981-0354> 



More information about the postgis-users mailing list