## Description TASK.md requires that the solution can in theory handle an arbitrarily large dataset. Today the database has 51 recipes, and the README and `docs/architecture.md` say scaling is not demonstrated. `apps/api/src/features/recipes/recipeRepository.ts` has three bottlenecks: - Search uses `strpos(lower(title || ' ' || description), lower($2))`, which no index can serve, so every search is a full table scan. - `highest_rated` sorts by a correlated `avg()` subquery, aggregating ratings for every matching row on each request. - `category` and `prep_minutes + cook_minutes` have no indexes but are used for filtering and the "quickest" sort. ## Tasks - [ ] Add a script that generates or imports 10,000–100,000 recipes (with ratings) into a dev database. - [ ] Migration: enable `pg_trgm` and add a GIN trigram index on `lower(title || ' ' || description)`; change the search condition to `ILIKE` so it uses the index. (Alternative: a `tsvector` column with a GIN index.) - [ ] Migration: add `rating_avg` and `rating_count` to `recipes`, maintained in the same transaction as `rate` and `removeRating`, with a backfill; sort `highest_rated` on the column. - [ ] Indexes for `category` and for the total-time expression. - [ ] Run `EXPLAIN ANALYZE` before and after on the large dataset and record the timings in `docs/performance-and-images.md`. - [ ] Load the large dataset on the VM. - [ ] Remove the "demonstrerer ikke ytelse med store datamengder" disclaimer from the README. ## Acceptance criteria - Search, filter and every sort use an index on a 10k+ dataset (shown with `EXPLAIN`). - Documented query times on the large dataset. - Existing DB and API integration tests pass; new tests cover the rating columns. Related: #80 (multi-word search) changes the same query. --- _Found in the final-delivery review (ref **M3**). Part of #39._