CREATE EXTENSION btree_gist; CREATE EXTENSION pg_trgm; CREATE EXTENSION bloom; drop table if exists t1,t2; CREATE TABLE t1 ( id text ); CREATE TABLE t2 ( id text primary key, t1_id text ); insert into t1 (id) select i::text FROM generate_series(1, 1500) as i; insert into t2 (id, t1_id) SELECT i::text, (i % 1500 + 1)::text FROM generate_series(1, 20000) i; ANALYZE t1, t2; SET random_page_cost = 0.00000001; -- SET random_page_cost = 1.0; SET enable_hashjoin = off; SET enable_mergejoin = off; SET enable_memoize = off; CREATE INDEX t1_btree_index ON t1 USING btree (id); explain (analyze, buffers) select * from t1 join t2 on t1.id = t2.t1_id ; DROP INDEX t1_btree_index; CREATE INDEX t1_gin_index ON t1 USING gin (id gin_trgm_ops); explain (analyze, buffers) select * from t1 join t2 on t1.id = t2.t1_id ; DROP INDEX t1_gin_index; CREATE INDEX t1_gist_index ON t1 USING gist (id); explain (analyze, buffers) select * from t1 join t2 on t1.id = t2.t1_id ; DROP INDEX t1_gist_index; CREATE INDEX t1_spgist_index ON t1 USING spgist (id); explain (analyze, buffers) select * from t1 join t2 on t1.id = t2.t1_id ; DROP INDEX t1_spgist_index; CREATE INDEX t1_hash_index ON t1 USING hash (id); explain (analyze, buffers) select * from t1 join t2 on t1.id = t2.t1_id ; DROP INDEX t1_hash_index; CREATE INDEX t1_brin_index ON t1 USING brin (id); explain (analyze, buffers) select * from t1 join t2 on t1.id = t2.t1_id ; DROP INDEX t1_brin_index; CREATE INDEX t1_bloom_index ON t1 USING bloom (id); explain (analyze, buffers) select * from t1 join t2 on t1.id = t2.t1_id ; DROP INDEX t1_bloom_index;