このトピックに関する以前の質問に続いて、複数のインデックスを組み合わせた Postgres :
Postgres 9.2(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
);
そして、テーブルで次のクエリを実行しています。
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
では、(coords + user_id)、GIST、または BTree にどのインデックスを使用すればよいでしょうか?
CREATE INDEX ix_coords_user_id ON updates USING GIST (coords, user_id);
また
CREATE INDEX ix_coords_user_id ON updates (coords, user_id);
BTree のパフォーマンスが GIST よりも優れていると読んでいましたが、postgis 地理フィールドを使用しているため、GIST を使用する必要がありますか??