Skip to content

Index in-stock product catalog queries - #121

Draft
ldennington wants to merge 1 commit into
mainfrom
copilot/task-11321782-1234088552-23649672-1706-45df-ae16-727844f089f1
Draft

ldennington wants to merge 1 commit into
mainfrom
copilot/task-11321782-1234088552-23649672-1706-45df-ae16-727844f089f1

Conversation

@ldennington

@ldennington ldennington commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Product listings repeatedly filter by inStock and sort by createdAt. This PR adds an index for that query pattern and records nine additional performance opportunities for follow-up.

  • Implemented: Add @@index([inStock, createdAt]) to Product and create the matching migration.
  • Other opportunities: Project only required fields; paginate catalog results; cap search results; add trigram search indexes; cache or revalidate product pages and search; guard short or stale searches; reduce cart-context-driven card rerenders; optimize product SVGs; index OrderItem foreign keys.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approved

No active review issues block the catalog-query index change.

No open issues 🎉

What changed in this PR

Adds a composite database index to support catalog queries that filter products by inStock and sort by createdAt. The other performance opportunities remain follow-up work.

Changes:

  • Declare the composite index on the Prisma Product model.
  • Add a matching SQL migration to create the index.
File Description
prisma/​schema.prisma Declares the composite index on inStock and createdAt.
prisma/​migrations/​20261123150245_add_product_catalog_index/​migration.sql Creates the matching Product_inStock_createdAt_idx database index.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants