Created
December 16, 2016 15:21
-
-
Save sofakingworld/ea98b0604bca02b92c5ae547639c21ca to your computer and use it in GitHub Desktop.
PSQL btree_gin index searching
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Making btree_gin index and using it in search | |
*/ | |
CREATE EXTENSION btree_gin; | |
create index ix_table_1 on table_1 USING GIN (to_tsvector('simple', coalesce(table_1.seach_field.value::text, '')), table_1.id) | |
select * from table_1 | |
where to_tsvector('simple', coalesce(table_1.seach_field.value::text, '')) @@ to_tsquery( 'example:*' ); | |
-- index used |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment