Skip to content

Instantly share code, notes, and snippets.

@wyattjoh
Last active July 11, 2016 19:05
Show Gist options
  • Save wyattjoh/2d314f60ccd43a628466fb9366f2367f to your computer and use it in GitHub Desktop.
Save wyattjoh/2d314f60ccd43a628466fb9366f2367f to your computer and use it in GitHub Desktop.
postgres=# EXPLAIN SELECT name FROM categories WHERE similarity(name, 'cr') > 0.3;
QUERY PLAN
----------------------------------------------------------------------------
Seq Scan on categories (cost=0.00..208.55 rows=2323 width=9)
Filter: (similarity((name)::text, 'cr'::text) > '0.3'::double precision)
(2 rows)
CREATE TABLE venue(
id VARCHAR(24) UNIQUE PRIMARY KEY
);
CREATE TABLE categories(
venue_id VARCHAR(24) REFERENCES venue(id) ON DELETE CASCADE,
name VARCHAR(30)
);
CREATE INDEX category_name_idx ON tags USING GIST(name gist_trgm_ops);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment