Ah, I see...I totally missed that last line.<div><br></div><div>Sorry.<br><br><div class="gmail_quote">On Tue, Dec 20, 2011 at 8:49 PM, Puneet Kishor <span dir="ltr"><<a href="mailto:punk.kish@gmail.com">punk.kish@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Dec 20, 2011, at 7:44 PM, Brian Stempin wrote:<br>
<br>
> I've been out of the loop for a bit, but try this:<br>
><br>
> SELECT Count(c_id)<br>
> FROM c, continents n<br>
> WHERE c.the_geom && n.the_geom AND<br>
> ST_Intersects(c.the_geom, n.the_geom) AND<br>
> n.continent = 'North America';<br>
><br>
> The key line being:<br>
> c.the_geom && n.the_geom<br>
><br>
<br>
<br>
</div>If you see the EXPLAIN QUERY PLAN I posted (see below), ST_Intersects automatically does an && check. Nevertheless, I tried your specific suggestion above, and it took 201 seconds. No joy.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
> Check out item 7.7:<br>
> <a href="http://postgis.refractions.net/documentation/manual-1.5/reference.html" target="_blank">http://postgis.refractions.net/documentation/manual-1.5/reference.html</a><br>
><br>
> The && uses the bounding boxes to check if they overlap. This is a very<br>
> quick operation that might eliminate the need to further examine if two<br>
> geoms are intersecting.<br>
><br>
> HTH,<br>
> Brian<br>
><br>
> On Tue, Dec 20, 2011 at 8:28 PM, Puneet Kishor <<a href="mailto:punk.kish@gmail.com">punk.kish@gmail.com</a>> wrote:<br>
><br>
>><br>
>> On Dec 20, 2011, at 7:21 PM, Paul Ramsey wrote:<br>
>><br>
>>> Chop up the continents into smaller pieces.<br>
>>><br>
>><br>
>><br>
>> hmmm... I am not sure I understand the above. And then what? UNION each<br>
>> smaller piece query?<br>
>><br>
>><br>
>>> On Tue, Dec 20, 2011 at 4:35 PM, Puneet Kishor <<a href="mailto:punk.kish@gmail.com">punk.kish@gmail.com</a>><br>
>> wrote:<br>
>>>> This is probably a really basic question... my ST_Within or<br>
>> ST_Intersects selecting points in a continent are way too slow (both take<br>
>> upward of 200 secs).<br>
>>>><br>
>>>> SELECT Count(c_id)<br>
>>>> FROM c, continents n<br>
>>>> WHERE ST_Intersects(c.the_geom, n.the_geom) AND<br>
>>>> n.continent = 'North America';<br>
>>>><br>
>>>><br>
>>>> Both tables have gist indexes on the geometries. The above query has<br>
>> the following plan<br>
>>>><br>
>>>> "Aggregate (cost=9.66..9.67 rows=1 width=4)"<br>
>>>> " -> Nested Loop (cost=0.00..9.66 rows=1 width=4)"<br>
>>>> " Join Filter: _st_intersects(c.the_geom, n.the_geom)"<br>
>>>> " -> Seq Scan on continents n (cost=0.00..1.10 rows=1<br>
>> width=32)"<br>
>>>> " Filter: ((continent)::text = 'North America'::text)"<br>
>>>> " -> Index Scan using pbdb__collections_the_geom on collections<br>
>> c (cost=0.00..8.30 rows=1 width=104)"<br>
>>>> " Index Cond: (c.the_geom && n.the_geom)"<br>
>>>><br>
>>>> The table c has approx 120K rows, and the continents table has 8<br>
>> rows.Suggestions on how I can improve this? Yes, the computer is otherwise<br>
>> very swift and modern.<br>
>>>><br>
>>>><br>
>>>><br>
>>>> --<br>
>>>> Puneet Kishor<br>
>><br>
<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br>
</div></div></blockquote></div><br></div>