Skip to content

Instantly share code, notes, and snippets.

@tsg
Last active March 1, 2024 11:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tsg/bc64fcea28fca844db11c65b9b1cb4ca to your computer and use it in GitHub Desktop.
Save tsg/bc64fcea28fca844db11c65b9b1cb4ca to your computer and use it in GitHub Desktop.
Loading recipes for search testing

Testing

CREATE TABLE recipes(
	title text,
	ingredients text,
	directions text,
	link text,
	source text,
	ner text, 
	site text);
\COPY recipes(title, ingredients, directions, link, source, ner, site) 
   FROM 'recipes_data.csv' DELIMITER ',' CSV HEADER;
ALTER TABLE recipes ADD search tsvector GENERATED ALWAYS AS
 (to_tsvector('english', title) || 
  to_tsvector('english', ingredients) || 
  to_tsvector('english', directions)) STORED;
ALTER TABLE
Time: 506514.510 ms (08:26.515)
CREATE INDEX idx_recipes_search ON recipes USING GIN(search);
CREATE INDEX
Time: 129500.090 ms (02:09.500)
CREATE INDEX idx_recipes_title ON recipes (title);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment