P
💻DeveloppementAdvancedChatGPT

Optimize Slow SQL Queries

Analyze and optimize your slow SQL queries through execution plan analysis and precise index recommendations.

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Tu es un expert en optimisation de bases de données avec une spécialisation en [PostgreSQL/MySQL/SQLite]. J'ai des requêtes SQL qui sont trop lentes en production et qui impactent les performances de mon application.

Requête problématique :

[COLLER_LA_REQUÊTE_SQL]

Résultat de l'EXPLAIN ANALYZE :

[COLLER_LE_RÉSULTAT_EXPLAIN_ANALYZE]

Contexte :

  • Nombre de lignes dans chaque table concernée : [EX: users: 500k, orders: 2M]
  • Index existants : [LISTER_LES_INDEX]
  • Temps d'exécution actuel : [EX: 3.2 secondes]
  • Objectif de performance : [EX: < 200ms]
  • Fréquence d'exécution : [EX: 500 fois/minute]

Analyse et optimise cette requête en :

  1. Lecture du plan d'exécution : explique chaque nœud de l'EXPLAIN ANALYZE et identifie les séquential scans, les hash joins coûteux et les estimations incorrectes.
  2. Index manquants : propose les index optimaux (simples, composites, partiels) avec le DDL SQL exact.
  3. Réécriture de la requête : propose une version optimisée de la requête avec explication des changements.
  4. Stratégies avancées : si applicable, suggère materialized views, partitionnement, CTEs ou dénormalisation.
  5. Monitoring : propose des métriques à surveiller pour détecter les régressions de performance.
100% found this useful

Personalize this prompt with Léa

Léa rewrites this prompt for your job and your exact goal — 3 quick questions.

Why this prompt works

<p>This prompt is structured to provide the AI with all the information needed for an accurate diagnosis: the query, execution plan, data volumes, and existing indexes. Without this context, recommendations would be generic and potentially counterproductive.</p><p>Requesting a commented reading of the EXPLAIN ANALYZE is particularly educational as it helps understand why the database makes certain decisions, which is essential for avoiding the same performance mistakes in the future.</p><p>By including execution frequency in the context, the AI can prioritize optimizations with the best ROI: a query executed 500 times per minute deserves more investment than one run once per day.</p>

Use Cases

Production database optimizationSQL performance auditIndex and execution plan training

Expected Output

An execution plan analysis, index recommendations with DDL SQL, the rewritten query, and advanced strategies if relevant.

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

Comments

  • LéaAI

    N'oublie pas d'exécuter `ANALYZE` sur toutes les tables avant de copier l'EXPLAIN ANALYZE : des statistiques obsolètes faussent les recommandations d'index et de réécriture de requête.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementAdvancedChatGPT

Master Advanced TypeScript Types

Strengthen your code's type safety with advanced generics, utility types, and discriminated unions.

39556
💻DeveloppementIntermediateAll AIs

Feature Flag Management

Progressive deployments with feature flags

0213
💻DeveloppementIntermediateAll AIs

Mistral Prompt for Creating a Software Architecture

Mistral, the leading French AI model, excels in designing software architectures thanks to its deep understanding of design patterns and technical constraints. Whether you're starting a new project or restructuring an existing application, Mistral can help you define a solid, scalable, and maintainable architecture. By providing a well-structured prompt, you will get detailed recommendations on architectural pattern choices, separation of concerns, appropriate technologies, and inter-service communication strategies. The AI analyzes your business, technical, and organizational constraints to propose a coherent architecture that anticipates future changes. This guide provides optimized prompts to get the most out of Mistral for creating software architectures, from modular monoliths to microservices, as well as event-driven and hexagonal architectures. Each prompt is designed to produce deliverables that can be immediately used by your development team.

0221
💻DeveloppementIntermediateAll AIs

Midjourney Prompt for Creating a Chatbot

Midjourney has become an essential tool for designing a chatbot's visual identity. Whether you're developing a virtual assistant for customer service, a conversational bot for your e-commerce site, or an AI companion for a mobile app, your chatbot's appearance plays a crucial role in user engagement. A well-designed avatar inspires trust, humanizes the interaction, and reinforces your brand image. With Midjourney, you can generate avatars, conversational interfaces, mascots, and UI visual elements without needing graphic design skills. The right prompts let you create visuals consistent with your brand guidelines, from accessible cartoon styles to clean corporate designs. In this guide, you'll find optimized prompts to generate all the visual assets your chatbot needs: main avatar, emotion variations, stylized speech bubbles, and welcome screens. Each prompt has been tested and refined to produce professional results you can use directly in your development projects.

0238