Summary
In internal/service/recipe.go:243-270, AssociateTagsWithRecipe executes a separate FindTagByName query for each hashtag extracted from a recipe. For a recipe with N tags, this produces N individual SELECT queries plus up to N individual INSERT queries.
Impact
Under load, recipes with many hashtags can generate dozens of sequential DB round-trips at generation time, increasing latency and DB load.
Suggested Fix
Batch-load existing tags with a single query:
SELECT * FROM tags WHERE hashtag IN (...)
Identify which tags are missing, then create them in a single batch insert. Associate all tags to the recipe in one INSERT ... ON CONFLICT DO NOTHING or equivalent batch operation.
Summary
In
internal/service/recipe.go:243-270,AssociateTagsWithRecipeexecutes a separateFindTagByNamequery for each hashtag extracted from a recipe. For a recipe with N tags, this produces N individualSELECTqueries plus up to N individualINSERTqueries.Impact
Under load, recipes with many hashtags can generate dozens of sequential DB round-trips at generation time, increasing latency and DB load.
Suggested Fix
Batch-load existing tags with a single query:
Identify which tags are missing, then create them in a single batch insert. Associate all tags to the recipe in one
INSERT ... ON CONFLICT DO NOTHINGor equivalent batch operation.