Postgresql gist index is not hit -
i using postgresql
version 9.3.
i learned normal b-tree
indexes can not used queries 'x%x%x' wildcards , find gist
, gin
indexes make wildcard queries hit index.
so decided use indexes , added btree-gist
extension using command in postgresql;
create extension btree_gist;
after added gist index table , ;
create index ix_bras_interface_name on bras_interface using gist (name);
after added this, see added;
table_name | index_name | column_name ----------------+-------------------------------------------+------------------- bras_interface | bras_interface_context_id | context_id bras_interface | bras_interface_domain_id | domain_id bras_interface | bras_interface_managed_object_id | managed_object_id bras_interface | bras_interface_name_59ec675d0b9537ac_uniq | context_id bras_interface | bras_interface_name_59ec675d0b9537ac_uniq | name bras_interface | bras_interface_name_idx | name bras_interface | bras_interface_pkey | id bras_interface | bras_interface_task_id | task_id **bras_interface | ix_bras_interface_name | name** (9 rows)
but, simple query still not hit index. here simple query , analyser result;
my_user=# explain analyze select * bras_interface name '%my_text%'; query plan ------------------------------------------------------------------------------------------------------------- seq scan on bras_interface (cost=0.00..764.95 rows=1 width=1420) (actual time=5.589..5.589 rows=0 loops=1) filter: ((name)::text ~~ '%my_text%'::text) rows removed filter: 27596 total runtime: 5.613 ms (4 rows)
and see not hitting index. followed tutorials , couldn't see solution, problem. missing gist indexing?
like a_horse_with_no_name has said, you've picked wrong extension.
the btree_gist extension lets use index "distance" operator. lets have gist index spanning multiple columns 1 might e.g. tsearch vector , simple int.
the pg_trgm extension 1 match-anywhere-in-string indexing. aware it's quite expensive index though.
Comments
Post a Comment