Index design: work back from queries
Give execution plan comparison and write cost
Prompt
Copy it whole, then replace the brackets with your own contentHandle this coding task: Index design: work back from queries. Code/error: [paste] Environment: [language/version/framework] Requirements: Compare execution plans and write cost. Give your assessment first, then the change, then how to verify it.
Replace the text in [ ] with your own situation; ask long tasks in stages.
How to get better results
Read this before you fill it inUse when you know which SQL is slow and need to design indexes.
Give the conclusion and impact scope first, then only the changed snippets (no full files), and finally one check that proves it works. Flag risky spots separately.
The orders table is queried by user_id + status + created_at and writes 50k rows a day; give an index plan and the write cost.
Giving indexes without the cost, writes slow down Not checking existing indexes, building duplicates Ignoring selectivity, the index is wasted
If problems remain after the fix, paste the new error and the changed snippet back; keep debugging on the original approach, don't switch approaches and rewrite.
More like this: Writing code prompts · All prompts