Skip to content

Instantly share code, notes, and snippets.

@sofakingworld
Created December 16, 2016 15:21
Show Gist options
  • Save sofakingworld/ea98b0604bca02b92c5ae547639c21ca to your computer and use it in GitHub Desktop.
Save sofakingworld/ea98b0604bca02b92c5ae547639c21ca to your computer and use it in GitHub Desktop.
PSQL btree_gin index searching
/*
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