P
💻DeveloppementIntermediateAll AIs

Optimize Your Prisma and Drizzle ORM Queries Like a Pro

A prompt to analyze your Prisma or Drizzle ORM queries and get concrete optimizations: N+1 elimination, targeted selection, indexes and verified SQL queries.

Paste in your AI

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

Tu es un expert en bases de données et en ORM JavaScript/TypeScript, spécialisé dans Prisma et Drizzle ORM. Analyse et optimise les requêtes suivantes pour améliorer les performances de mon application.

Contexte du projet :

  • ORM utilisé : [PRISMA | DRIZZLE]
  • Base de données : [POSTGRESQL | MYSQL | SQLITE]
  • Description du modèle de données : [DÉCRIRE LES TABLES/MODÈLES PRINCIPAUX ET LEURS RELATIONS]
  • Requêtes à optimiser :
[COLLER VOS REQUÊTES ORM ICI]
  • Problème observé : [LENTEUR | REQUÊTES N+1 | CONSOMMATION MÉMOIRE | TIMEOUT]

Pour chaque requête, fournis :

  1. Diagnostic : Identifie les problèmes de performance (requêtes N+1, select *, jointures manquantes, absence d'index, chargement eager vs lazy inadapté).

  2. Requête optimisée : Réécris la requête avec les bonnes pratiques :

    • Sélection des champs nécessaires uniquement (select/columns)
    • Utilisation correcte des includes/relations/with
    • Pagination côté base de données
    • Agrégations côté SQL plutôt que JavaScript
    • Transactions quand nécessaire
  3. Index recommandés : Propose les index à créer dans le schéma (migration) pour supporter ces requêtes.

  4. Requête SQL générée : Montre la requête SQL brute équivalente pour vérifier ce que l'ORM produit réellement.

  5. Métriques attendues : Estime le gain de performance (nombre de requêtes SQL réduites, volume de données transférées).

Présente chaque optimisation dans un bloc de code TypeScript commenté, avec un avant/après clair.

Personalize this prompt with Léa

Answer 3 questions and Léa tailors the prompt to your situation.

Why this prompt works

<p>This prompt transforms AI into a specialized database performance consultant via ORM. By providing your actual queries and schema context, you get a precise diagnosis of common anti-patterns like N+1 queries, unnecessary <strong>select *</strong> or misconfigured joins.</p><p>The before/after approach is essential: it shows you not only the optimized query but also the <strong>underlying SQL query</strong> generated by the ORM. This helps you understand what is actually happening on the database side and verify that the ORM produces what you expect.</p><p>For better results, include your <strong>Prisma schema or Drizzle table definitions</strong> in the data model variable. The more precise the context (relationship cardinality, data volume, read/write use cases), the more relevant the index and restructuring recommendations will be.</p>

Use Cases

Eliminate N+1 queries in a REST or GraphQL APIOptimize listing pages with pagination and complex filtersReduce dashboard response times with heavy aggregations

Expected Output

A structured report for each query with problem diagnosis, optimized ORM query in TypeScript, SQL indexes to create, equivalent raw SQL query and estimated performance gains.

Improve this prompt

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

Improve this prompt with the Optimizer

Comments

Be the first to comment on this prompt.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementAdvancedAll AIs

Optimize bundle size

Reduce JavaScript bundle size

080
💻DeveloppementIntermediateAll AIs

Namespace and Quota Management

Manage a multi-tenant cluster

065
💻DeveloppementIntermediateAll AIs

GitHub Copilot Prompt for Generating SQL Queries

GitHub Copilot is radically transforming how developers write SQL queries on a daily basis. Integrated directly into your code editor, this AI assistant understands your project context — table schemas, entity relationships, naming conventions — to generate precise and optimized SQL queries. Whether you work with PostgreSQL, MySQL, SQL Server, or SQLite, Copilot adapts to the specific syntax of your database engine. The challenge is not just to generate functional SQL, but to obtain performant, readable, and maintainable queries. A well-structured prompt enables Copilot to produce complex joins, correlated subqueries, window functions, and aggregation queries that follow best practices. By providing your table schema, expected output, and performance constraints, you get production-ready queries rather than drafts that need reworking. This guide offers an optimized main prompt as well as variants suited to your skill level, to fully leverage Copilot in generating reliable and performant SQL queries.

064
💻DeveloppementIntermediateAll AIs

GitHub Copilot Prompt for Debugging Code

Debugging is one of the most time-consuming tasks in software development. GitHub Copilot, integrated directly into your code editor, can significantly speed up this process by analyzing your code, identifying likely causes of a bug, and suggesting targeted fixes. Unlike manual searches on Stack Overflow or in documentation, Copilot has access to the full context of your file and project, allowing it to provide more relevant diagnostics. Whether you are facing a runtime error, unexpected behavior, or a performance issue, a well-structured prompt enables Copilot to act as an experienced pair programmer reviewing your code with fresh eyes. The goal is not simply to fix a line, but to understand the root cause of the problem to prevent it from recurring. In this guide, you will find optimized prompts to fully leverage GitHub Copilot's debugging capabilities, suited for different expertise levels and common bug types encountered daily.

057