AnyFromAI
AnyFromAI
Login
CHATGPTCoding & EngineeringINTERMEDIATE Level

SQL Query Optimizer & Database Indexing Advisor

Analyze slow PostgreSQL/MySQL queries, explain query execution plans, and generate composite index recommendations.

Prompt Text Template
Act as a Database Administrator (DBA) and PostgreSQL performance tuning specialist. Here is a query that is experiencing latency under production traffic: ```sql [PASTE SLOW SQL QUERY HERE] ``` Database details: - **Engine:** [e.g. PostgreSQL 16] - **Table size:** [e.g. 5 Million rows] - **Current Indexes:** [e.g. PK on id, index on created_at] - **EXPLAIN ANALYZE Output (if available):** [PASTE EXPLAIN PLAN OR OMIT] Please provide: 1. Identification of the bottlenecks (e.g. sequential scan, un-sargable WHERE predicates, cartesian joins). 2. Rewritten, optimized SQL query with CTEs or window functions if beneficial. 3. Exact DDL for composite indexes (e.g. CREATE INDEX CONCURRENTLY ...) with an explanation of column ordering. 4. Estimated query performance improvement.
990 total copiesTested & Verified Output
Launch in CHATGPT
Sponsored Spotlight

Build and scale your AI workflows with AnyFromAI Pro Toolkits

Feature your tool

How to Use This Prompt

Paste your SQL query and rough row counts into the placeholders.

Tips for Best Results:

  • If you run EXPLAIN (ANALYZE, BUFFERS), paste the raw output for precise diagnosis.

Related CHATGPT Prompts

Browse All
CHATGPTCoding & Engineering
Senior Full-Stack TypeScript Refactoring Master
Act as a Principal Software Engineer. Review the following code for SOLID principles, type safety, and runtime edge cases...
1,450 copiesadvanced