Prompt Details
Model
(claude-5-sonnet)
Token size
2,605
Example input
[RAW_REQUEST]: Optimize a PostgreSQL 15 SELECT query joining 'users' (50k rows) and 'orders' (2M rows). Current query uses nested subqueries, takes 8+ seconds. Target: under 300ms. Need optimized SQL with explicit JOINs/CTEs, missing index suggestions, and EXPLAIN ANALYZE breakdown.
Example output
---
π Quality Score: 78% (v-1) β heuristic estimate, not a precise measurement
(0-49% Needs major work | 50-74% Basic, gaps exist | 75-89% Good, minor gaps | 90-99% Professional | 100% Ready to send)
Reason: Clear technical goal and measurable target are present, but the actual query text, schema, and existing indexes are missing.
Requester Profile: Aware β uses precise technical vocabulary (PostgreSQL 15, CTEs, EXPLAIN ANALYZE) but omits the artifacts (query text, schema) a Pro would typically attach.
Domain: IT
Readiness Check:
- Goal: Present β "Optimize a PostgreSQL 15 SELECT query joining 'users' (50k rows) and 'orders' (2M rows)"
- Expected Output: Present β "Need optimized SQL with explicit JOINs/CTEs, missing index suggestions, and EXPLAIN ANALYZE breakdown"
- Success Criteria: Present β "Target: under 300ms"
- Context: Partial β "Current query uses nested subqueries, takes 8+ seconds"
- Constraints: Partial β "'users' (50k rows) and 'orders' (2M rows)"
- Target Audience: Missing β no supporting text found
π Safety Review:
- Injection attempt: Missing
- PII exposure: Missing
- Unflagged claims: Not Applicable β no medical/legal/financial commitments are present in this brief
β οΈ Risks (ranked by severity):
High: Risk β no actual SQL provided / Evidence: the request describes the query's structure ("uses nested subqueries") but never includes the query text or table schema / Impact: any optimized query written without the real query risks not matching the actual logic, columns, or data types.
Medium: Risk β no existing index list / Evidence: "missing index suggestions" is requested with no mention of current indexes / Impact: recommended indexes could duplicate existing ones or miss relevant composite index opportunities.
Medium: Risk β no environment/hardware detail / Evidence: no mention of server specs, connection pooling, or read replicas / Impact: the 300ms target's achievability partly depends on hardware, which can't be verified here.
Low: Risk β target audience/use context absent / Evidence: no supporting text found / Impact: minor, since this is a self-contained technical task.
π‘ Recommendations:
High: Attach the exact current SQL query and the schemas (column names/types) for 'users' and 'orders'.
Medium: List existing indexes on both tables so suggestions don't overlap or conflict.
Medium: Share basic environment details (RAM, storage type, Postgres config, whether this runs on a replica).
Low: Clarify whether this is for production tuning or a one-off analysis, to set appropriate rollout caution.
Optimized Request:
Optimize a PostgreSQL 15 SELECT query joining the 'users' table (50,000 rows) and 'orders' table (2,000,000 rows). The current query uses nested subqueries and takes 8+ seconds to execute. The target performance is under 300ms. (assumption: the query runs on a single primary database instance without read replicas). (assumption: existing indexes are limited to primary keys only, since no index information was provided). Please provide: an optimized SQL query using explicit JOINs and/or CTEs instead of nested subqueries; suggestions for any missing indexes on the 'users' and 'orders' tables that would support the optimized query; and a breakdown of the EXPLAIN ANALYZE output showing the resulting performance improvement. (assumption: the full query text and table schemas, including column names and data types, will be supplied separately, as they were not included in this request).
π Score Comparison:
Original Score: 78% β clear goal and metric, but missing query/schema and index context
Improved Score: 87% β gaps are now explicitly flagged as assumptions rather than silent omissions, but full completeness credit is withheld since Context, Constraints, and Target Audience are only assumption-filled, not user-supplied
Improvement: +9 points (v-2)
---
βΉοΈ This tool audits and improves the wording and completeness of the request β it doesn't verify factual, legal, or financial accuracy. Scores reflect a structured heuristic, not a precise measurement; wording and scores may vary slightly between runs. Final decisions remain the requester's responsibility.
β A few quick questions that would raise this above 90% β the Optimized Request above is ready to use as-is:
β Q1: Can you paste the actual current SQL query (including the nested subqueries)?
β Q2: What indexes currently exist on 'users' and 'orders' (if any beyond primary keys)?
β Q3: What's the server environment β RAM, storage type, and whether reads hit a replica or the primary?
By purchasing this prompt, you agree to our terms of service
CLAUDE-5-SONNET
π Audit any client request or project brief β freelance, agency, or email. Get a 6-component readiness check (Goal, Output, Success Criteria, Context, Constraints, Audience), π safety & prompt-injection scan, a 0-100% quality score, and a complete ready-to-send rewrite with assumptions clearly marked. Includes a before/after score comparison and up to 3 refinement passes per session.
β οΈ Analysis tool only, not liable for outcomes. Do not submit confidential data. Validated on Claude Sonnet 5.
...more
Added 2 days ago
