[postgis-users] Why postgis doesn't use index during query?

Pietro Rossin pierigis at gmail.com
Tue Jan 22 06:38:22 PST 2013


Hello
I have a table with about 6.000.000 polilines records.
The geometry value is in the_geom column.
I made an index with this instruction

*************
CREATE INDEX idx_polilineegb_geom
  ON gauss_b.polilineegb
  USING gist
  (the_geom );
*************

If I try a query like this:
**********************
SELECT the_geom, layer, id
  FROM gauss_b.polilineegb
  where
  (st_xmin(the_geom)=2365385 and st_ymin(the_geom)=5075215) and
(st_xmax(the_geom)=2366019 and st_ymax(the_geom)=5075752);
**********************

It takes ages to execute..
I take a look at the explain query it says:

************************
"Seq Scan on polilineegb  (cost=0.00..727911.08 rows=1 width=2924)"
"  Filter: ((st_xmin((the_geom)::box3d) = 2365385::double precision) AND
(st_ymin((the_geom)::box3d) = 5075215::double precision) AND
(st_xmax((the_geom)::box3d) = 2366019::double precision) AND
(st_ymax((the_geom)::box3d) = 5075752::double precision))"
************************
This is a Seq Scan, so it doesn't use the index, right?
Why?
Is there some more performing index to be used??

Thank you
Pietro





--
View this message in context: http://postgis.17.n6.nabble.com/Why-postgis-doesn-t-use-index-during-query-tp5002377.html
Sent from the PostGIS - User mailing list archive at Nabble.com.


More information about the postgis-users mailing list