<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7600.16625"></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=738464215-22092010><FONT color=#0000ff 
size=2 face=Arial>&& does a bounding box intersects check where as 
ST_Intersects does a more intensive actual geometry intersect check.  Which 
is why its slower.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=738464215-22092010><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=738464215-22092010><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN> </DIV><BR>
<DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>From:</B> 
postgis-users-bounces@postgis.refractions.net 
[mailto:postgis-users-bounces@postgis.refractions.net] <B>On Behalf Of 
</B>Andreas Forø Tollefsen<BR><B>Sent:</B> Wednesday, September 22, 2010 11:00 
AM<BR><B>To:</B> PostGIS Users Discussion<BR><B>Subject:</B> [postgis-users] 
Difference between ST_Intersects and && operator<BR></FONT><BR></DIV>
<DIV></DIV>Hi all.
<DIV>I am working on a huge vector grid project where i need to intersect 
country polygon data and vector grid cells.</DIV>
<DIV>For this i need to first select the grid cells which intersects with the 
country polygons.</DIV>
<DIV><BR></DIV>
<DIV>SELECT DISTINCT testgrid.gid, xcoord, ycoord, cell INTO testgrid2 FROM 
testgrid, cshaperef WHERE ST_Intersects(cshaperef.the_geom, 
testgrid.cell)=true</DIV>
<DIV><BR></DIV>
<DIV>I tried both the ST_Intersects and the && operator, but i cannot 
really understand the difference.</DIV>
<DIV>After looking at my results the ST_Intersects gave exactly the cells which 
intersected with the country polygons, while the && gave many additional 
cells.</DIV>
<DIV>Another interesting observation is the the && is way faster than 
the ST_Intersects which in my case 188 polygons and 212000 cells takes a lot of 
time.</DIV>
<DIV><BR></DIV>
<DIV>Could anyone please elaborate on the difference?</DIV>
<DIV><BR></DIV></BODY></HTML>