sql - PostGIS query not using gist index when doing a ST_DUMP(ST_UNION -
my query:
drop table if exists tmp; create temp table tmp select *, st_buffer(the_geom::geography, 3000)::geometry buffer af_modis_master limit 20000; create index idx_tmp_the_geom on tmp using gist(buffer); explain select (dump(st_union(buffer))).path[1], (dump(st_union(buffer))).geom tmp;
output explain:
aggregate (cost=1705.52..1705.54 rows=1 width=32) -> seq scan on tmp (cost=0.00..1625.01 rows=16101 width=32)
seq scan means not using index, right? why not?
(this question first posted here: http://gis.stackexchange.com/questions/51877/postgis-query-not-using-gist-index-when-doing-a-st-dumpst-union . apologies reposting community here much more active, perhaps wil provide reply quicker.)
update: adding clause filters based on buffer causes seq scan:
analyze tmp; explain select (dump(st_union(buffer))).path[1], (dump(st_union(buffer))).geom tmp st_xmin(buffer) = 0.0;
a query have never utilize index ever. substitute important random disk i/o (possibly in add-on normal disk i/o) scan of table.
in essence not selecting on criteria index slower pulling info disk in physical order , processing it.
now if pull single row status index might help with, may find may utilize index, or not, depending on how big table is. little tables never utilize indexes because random disk i/o never win. remember no query plan beats sequential scan through single page....
sql postgresql postgis spatial-index
No comments:
Post a Comment