🔒

Unlock Pro Access

Get unlimited access to all premium prompts and save your favourites.

$5
One-time payment · No subscription · Instant access
600+ exclusive premium prompts
Save prompts across sessions
All future prompt additions
Early access to new categories
Upgrade for $5 →
Gemini Coding

Write a Database Query Optimization Guide

Prompt
Create a query optimization plan for [database]. Include indexing strategies, slow query analysis, and execution plan review. Focus on performance.
Why it works

Query optimization often provides the highest performance ROI in applications.

When you're looking to speed up your database application, query optimization is often the highest-impact change you can make. This Gemini prompt generates a comprehensive optimization plan by analyzing your database structure and identifying performance bottlenecks. It's designed for developers, database administrators, and technical leads who need to improve application response times without major architectural changes. Whether you're working with PostgreSQL, MySQL, MongoDB, or another database system, this prompt guides you through a structured approach to finding and fixing slow queries.

To use this prompt effectively, replace the [database] placeholder with your specific database system and ideally include details about your current performance issues. For example, you might write "Create a query optimization plan for PostgreSQL e-commerce database that handles user orders, products, and inventory with slow reports taking 30 seconds to generate." The more context you provide about your actual pain points, the more targeted and useful the recommendations will be.

When you send this prompt to Gemini, expect a detailed optimization guide that covers three critical areas. First, you'll get indexing strategies that explain which columns to index and why, with specific recommendations for compound indexes if needed. Second, the output includes techniques for analyzing slow queries, like using EXPLAIN PLAN to understand execution details. Third, you'll receive a step-by-step execution plan review process that shows how to interpret query execution plans and identify expensive operations.

One pro tip for better results is to include sample query examples that are currently running slowly. If you paste an actual SQL query that's causing performance problems, Gemini can provide more specific optimization suggestions rather than generic guidance. You can also ask follow-up questions about specific indexes or query rewrites, since Gemini maintains context throughout your conversation. This makes it easy to iteratively improve your database performance based on real results from your testing environment.