Promptory Logo
Promptory

PostgreSQL Query Optimization & Index Tuning Prompt

Transform slow sequential scans into index-backed execution plans for high-write databases. This system prompt is engineered to assist Developer teams in executing high-precision database workflows. It leverages DeepSeek's reasoning capabilities to analyze complex parameters, structure high-signal outputs, and eliminate conversational filler. The blueprint enforces strict negative boundary constraints, reduces token overhead, and maintains structured fidelity across both rapid prototyping and production pipelines.

Customize Template Variables

Live Generated Prompt

3 Free Used (Locked)
Act as a Lead Database Administrator. Given the following PostgreSQL schema and slow query execution plan EXPLAIN ANALYZE
output: [QUERY_PLAN], recommend composite partial indexes, query restructuring, and VACUUM settings to drop p99 latency below [TARGET_LATENCY_MS] ms.
Free Quota Exhausted (3/3 Used)

You have reached the 3 free prompt limit. Upgrade to Promptory Pro for ₹799/mo to unlock unlimited blueprints and export tools.

Live AI Output Simulator

3 Free Trial Runs

Test this compiled prompt instantly across frontier open-weights models to verify response fidelity.

Open Directly in AI App

Auto-copies prompt to clipboard on click

Demonstrated AI Execution Output

Observed execution telemetry when evaluated across DeepSeek

● Model Target: DeepSeekEfficiency: 94.2% | Latency: <45ms

Strategic Deliverable Blueprint for Developer

When applied to real-world workflows, this prompt instructs the AI engine to eliminate conversational preamble, apologies, and generic pleasantries. The output enforces hierarchical Markdown formatting with actionable, zero-fluff recommendations designed specifically for Developer teams.

Negative Constraints & Boundary Guards

  • Zero Hallucination Tolerance: The model is constrained to explicitly flag missing variables rather than guessing arbitrary facts.
  • Context Window Efficiency: By stripping repetitive instructions, 100% of the active token budget is allocated to substantive analysis for Database.
  • Reproducible Output Determinism: Yields identical structured deliverables across Claude 3.5 Sonnet, DeepSeek-R1, and GPT-4o environments.

Cross-Engine Execution Nuances

Claude 3.5 Sonnet

Applies strict semantic constraint adherence with deep variable isolation, perfect for intricate code and architectural briefs.

DeepSeek-R1

Leverages chain-of-thought self-correction before output emission, making it ideal for edge-case reasoning and validation.

OpenAI ChatGPT-4o

Delivers high token throughput with rapid markdown table formatting and deterministic instruction execution.

How to Execute This Database Workflow

Production execution protocol for developers and engineering teams

4-Phase Implementation

01. Ingest DDL Schema & Execution Telemetry

Provide table schema, current index definitions, and the EXPLAIN ANALYZE output or slow query log. Specifying row volume (e.g., 5M rows) ensures the model accounts for sequential scan costs.

Provide actual indexing structure to avoid duplicate index recommendations.

02. Set Dialect Constraints & Isolation Levels

Specify your exact database engine (PostgreSQL 16, MySQL 8, SQLite, Supabase) and concurrency limits. Negative constraints prevent the engine from suggesting generic incompatible syntax.

Verify transaction isolation requirements and vacuum/connection pool limits.

03. Simulate Plan Optimization & Index Synthesis

Test the compiled query prompt in the Simulator to inspect composite index proposals, partial index strategies, and CTE refactoring suggestions for latency reduction.

Compare proposed query execution time against original sequential scan telemetry.

04. Benchmark in Staging Before Production Migration

Copy optimized SQL statements and run them in an isolated staging branch using `EXPLAIN (BUFFERS, ANALYZE)` to confirm buffer hit ratios improve before creating migration scripts.

Confirm zero locking regressions on active write tables during index creation.

Frequently Asked Questions

In-depth technical execution and architecture guidance

Schema.org FAQPage Verified
Which database engines and SQL dialects are supported?▼

This prompt is optimized for PostgreSQL (including Supabase), MySQL 8+, SQLite, CockroachDB, and MongoDB aggregation pipelines. Explicitly provide your dialect in the input variables for accurate optimization syntax.

Does this prompt provide EXPLAIN ANALYZE interpretation?▼

Yes. If you paste your raw execution plan or slow query log into the variables, the prompt breaks down cost nodes, flags Sequential Scans on large tables, and highlights buffer bottlenecks.

How does it decide between composite indexes, partial indexes, and query rewriting?▼

The prompt applies deterministic index synthesis: it prioritizes query refactoring (stripping SELECT *, flattening subqueries) first, followed by partial indexes for filtered states, and composite indexes aligned with equality-then-range filtering order.

Can I test the performance of the generated SQL in the simulator?▼

You can test the reasoning fidelity in our Live Simulator. For staging execution, copy the generated migration SQL and execute with 'EXPLAIN (BUFFERS, ANALYZE)' in your local database environment.

Related Technical Workflows

Semantically matched workflows in this domain

AI ModelEngineer

DeepSeek-R1 Autonomous SQL EXPLAIN & Index Profiler Prompt

structured PostgreSQL query planner optimizer. Analyzes slow sequential scans, buffer hits, and outputs zero-downtime concurrent index queries. This system prompt is engineered to assist Engineer teams in executing high-precision production workflows. It leverages AI Model's reasoning capabilities to analyze complex parameters, structure high-signal outputs, and eliminate conversational filler. The blueprint enforces strict negative boundary constraints, reduces token overhead, and maintains structured fidelity across both rapid prototyping and production pipelines.

Score 100/100View Prompt
ChatGPTDeveloper

Senior Rust Performance & Memory Profiler Prompt

Analyzes Rust Axum and Tokio code to eliminate heap allocations and optimize concurrency. This system prompt is engineered to assist Developer teams in executing high-precision production workflows. It leverages ChatGPT's reasoning capabilities to analyze complex parameters, structure high-signal outputs, and eliminate conversational filler. The blueprint enforces strict negative boundary constraints, reduces token overhead, and maintains structured fidelity across both rapid prototyping and production pipelines.

Score 100/100View Prompt
ChatGPTReal Estate Agent

Real Estate Agent Security Prompt

This system prompt equips a real‑estate agent with a specialized security assistant that evaluates client data, property details, and desired security level to produce compliant, GDPR‑aware communication plans, access controls, and incident response procedures. The assistant operates within the constraints of the ChatGPT context window, ensuring that all generated content is concise, context‑aware, and free of disallowed personal data. Runtime efficiency is achieved by limiting the prompt to essential variables and by using structured templates that avoid unnecessary back‑and‑forth. The prompt is designed for production use in high‑volume real‑estate workflows.

Score 99/100View Prompt
AI ModelEngineer

Next.js 15 + Supabase Production .cursorrules Engine Prompt

structured context IDE rule configuration for App Router, Server Actions, TypeScript strict types, and Supabase SSR authentication. This system prompt is engineered to assist Engineer teams in executing high-precision production workflows. It leverages AI Model's reasoning capabilities to analyze complex parameters, structure high-signal outputs, and eliminate conversational filler. The blueprint enforces strict negative boundary constraints, reduces token overhead, and maintains structured fidelity across both rapid prototyping and production pipelines.

Score 99/100View Prompt
DeepSeekDeveloper

Pytest & Playwright Testing & Performance Prompt

Automated audit rules and high-throughput architectural guidelines for Pytest & Playwright applications. This system prompt is engineered to assist Developer teams in executing high-precision testing workflows. It leverages DeepSeek's reasoning capabilities to analyze complex parameters, structure high-signal outputs, and eliminate conversational filler. The blueprint enforces strict negative boundary constraints, reduces token overhead, and maintains structured fidelity across both rapid prototyping and production pipelines.

Score 99/100View Prompt
DeepSeekDeveloper

Rust Axum Testing & Performance Prompt

Automated audit rules and high-throughput architectural guidelines for Rust Axum applications. This system prompt is engineered to assist Developer teams in executing high-precision performance workflows. It leverages DeepSeek's reasoning capabilities to analyze complex parameters, structure high-signal outputs, and eliminate conversational filler. The blueprint enforces strict negative boundary constraints, reduces token overhead, and maintains structured fidelity across both rapid prototyping and production pipelines.

Score 99/100View Prompt