Im Anschluss an meiner vorherigen Frage zu diesem Thema Postgres combining multiple Indexes:Postgres GIST vs Btree Index
Ich habe die folgende Tabelle auf Postgres 9.2 (mit 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
);
Und ich bin mit Abfrage folgend auf dem Tisch:
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
Also da, was Index sollte ich für (coords + user_id), GIST oder BTree?
CREATE INDEX ix_coords_user_id ON updates USING GIST (coords, user_id);
ODER
CREATE INDEX ix_coords_user_id ON updates (coords, user_id);
Ich las, dass BTree als GIST besser abschneidet, aber bin ich GIST zu verwenden gezwungen, da ich postgis Geographie Feld bin mit ??
Bitte zeigen Sie 'erklären analysieren' für beide; Fügen Sie die Pläne auf http://explain.depesz.com/ ein und verlinken Sie sie hier. –