<div dir="ltr">Hi,<div><br></div><div style>GIST index is only used with GIST operators: </div><div style>&&, st_intersects, st_touches, etc.</div><div style><br></div><div style>You should rewrite your query to define a geographic bounding box and test your data against it:</div>
<div style><br></div><div style><span style="font-family:arial,sans-serif;font-size:13px">SELECT the_geom, layer, id</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">  FROM gauss_b.polilineegb</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">  where the_geom && 'BOX(</span><span style="font-family:arial,sans-serif;font-size:13px">2365385 </span><span style="font-family:arial,sans-serif;font-size:13px">5075215, </span><span style="font-family:arial,sans-serif;font-size:13px">2366019 </span><span style="font-family:arial,sans-serif;font-size:13px">5075752</span><span style="font-family:arial,sans-serif;font-size:13px">)'::box2d;</span></div>
<div style><br></div><div style><span style="font-family:arial,sans-serif;font-size:13px">Nicolas</span></div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 22 January 2013 15:38, Pietro Rossin <span dir="ltr"><<a href="mailto:pierigis@gmail.com" target="_blank">pierigis@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello<br>
I have a table with about 6.000.000 polilines records.<br>
The geometry value is in the_geom column.<br>
I made an index with this instruction<br>
<br>
*************<br>
CREATE INDEX idx_polilineegb_geom<br>
  ON gauss_b.polilineegb<br>
  USING gist<br>
  (the_geom );<br>
*************<br>
<br>
If I try a query like this:<br>
**********************<br>
SELECT the_geom, layer, id<br>
  FROM gauss_b.polilineegb<br>
  where<br>
  (st_xmin(the_geom)=2365385 and st_ymin(the_geom)=5075215) and<br>
(st_xmax(the_geom)=2366019 and st_ymax(the_geom)=5075752);<br>
**********************<br>
<br>
It takes ages to execute..<br>
I take a look at the explain query it says:<br>
<br>
************************<br>
"Seq Scan on polilineegb  (cost=0.00..727911.08 rows=1 width=2924)"<br>
"  Filter: ((st_xmin((the_geom)::box3d) = 2365385::double precision) AND<br>
(st_ymin((the_geom)::box3d) = 5075215::double precision) AND<br>
(st_xmax((the_geom)::box3d) = 2366019::double precision) AND<br>
(st_ymax((the_geom)::box3d) = 5075752::double precision))"<br>
************************<br>
This is a Seq Scan, so it doesn't use the index, right?<br>
Why?<br>
Is there some more performing index to be used??<br>
<br>
Thank you<br>
Pietro<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://postgis.17.n6.nabble.com/Why-postgis-doesn-t-use-index-during-query-tp5002377.html" target="_blank">http://postgis.17.n6.nabble.com/Why-postgis-doesn-t-use-index-during-query-tp5002377.html</a><br>

Sent from the PostGIS - User mailing list archive at Nabble.com.<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
</blockquote></div><br></div>