W nawiązaniu do mojego poprzedniego pytania na ten temat, Postgres combining multiple Indexes:Postgres GIST vs indeksu btree
mam następującą tabelę na PostgreSQL 9.2 (z PostGIS):
CREATE TABLE updates (
update_id character varying(50) NOT NULL,
coords geography(Point,4326) NOT NULL,
user_id character varying(50) NOT NULL,
created_at timestamp without time zone NOT NULL
);
I używam następujące kwerendy na stole:
select *
from updates
where ST_DWithin(coords, ST_MakePoint(-126.4, 45.32)::geography, 30000)
and user_id='3212312'
order by created_at desc
limit 60
Więc biorąc pod uwagę, że co Index należy używać do (koordy + user_id), GIST lub btree?
CREATE INDEX ix_coords_user_id ON updates USING GIST (coords, user_id);
LUB
CREATE INDEX ix_coords_user_id ON updates (coords, user_id);
czytałem że btree działa lepiej niż GIST, ale jestem zmuszony do korzystania z GIST, ponieważ używam pole geografii postgis ??
Proszę pokazać "wyjaśnij analizę" dla obu; wklej plany na http://explain.depesz.com/ i link do nich tutaj. –