[postgis-users] Query without index faster than query with index (using GIST)

Marcello Benigno benigno.marcello at gmail.com
Thu Feb 14 15:36:26 PST 2013


Hello everybody,

I wonder why this is happening, all tables are with indexes and has already
run a vacuum analyze to all of them:

SELECT ms_ucs,
SUM(ST_Area(Geography((ST_Intersection(analises.pol_geom,ms_2010_s1.geom)))))/10000
AS area_ha
FROM analises, ms_2010_s1
WHERE analises.pol_geom && ms_2010_s1.geom
AND ST_Intersects(analises.pol_geom,ms_2010_s1.geom)
GROUP BY ms_ucs; *-- 889 ms*

SELECT ms_ucs,
SUM(ST_Area(Geography((ST_Intersection(analises.pol_geom,ms_2010_s1.geom)))))/10000
AS area_ha
FROM analises, ms_2010_s1
WHERE ST_Intersects(analises.pol_geom,ms_2010_s1.geom)
GROUP BY ms_ucs; *-- 870 ms !!!*

Please note that the second, without using the && operator was faster,
there's something wrong or I'm not understanding the functioning of the
index?

Thanks in advance,
-- 
*Marcello Benigno B. de Barros Filho*
Prof. do Curso Superior de Tecnologia em Geoprocessamento - IFPB
Mestre em Ciências Geodésicas e Tecnologias da Geoinformação - UFPE
Doutorando em Tecnologia Ambiental e Recursos Hídricos - UFPE
http://profmarcello.blogspot.com
http://about.me/marcello.benigno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130214/8970ecaa/attachment.html>


More information about the postgis-users mailing list