Skip to content

Instantly share code, notes, and snippets.

@itsdevsunny
Forked from tsg/recipes.md
Created November 30, 2024 18:33
Show Gist options
  • Save itsdevsunny/15371be5038f4cc890275d0f44a40a6a to your computer and use it in GitHub Desktop.
Save itsdevsunny/15371be5038f4cc890275d0f44a40a6a 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