Skip to main content

ChatGPT Prompt to Diagnose and Fix Performance Bottlenecks

Diagnose N+1 queries, memory leaks, slow APIs, and bloated bundles with targeted code fixes and per-bottleneck improvement estimates.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
Analyze my web application for performance bottlenecks. Current issues: slow page loads, high TTFB. Stack: Laravel, MySQL, Redis, Vite. Investigate: 1) Database query optimization (N+1, missing indexes, slow queries), 2) Redis caching strategy, 3) Memory usage and potential leaks, 4) Frontend performance (bundle size, render blocking, lazy loading), 5) API response time optimization. Current metrics: TTFB 800ms, LCP 3.2s. Target: TTFB under 200ms, LCP under 2.5s. Provide specific code fixes and expected improvement for each optimization.

What this prompt does

This prompt turns ChatGPT into a structured performance audit session for a specific application. Rather than asking vague questions like "how do I make my app faster," the template forces you to supply concrete symptoms and current metrics upfront — which means the AI can reason about trade-offs rather than give generic advice. The five numbered investigation areas in the template are not arbitrary; they map to the most common performance failure modes across web applications, from ORM misuse to frontend render blocking.

What makes it effective is the [current_metrics] and [target_metrics] pairing. By anchoring the conversation to real numbers (e.g., p95 API latency at 1.4s, target 300ms), you get prioritized fixes rather than a laundry list. The prompt also requests expected improvement per optimization, which gives you a rough ROI signal before you spend hours implementing anything.

When to use it

  • Your Laravel or Django app is under load and slow queries are showing up in Telescope or the slow query log but you are not sure which ones matter most.
  • A React or Vue bundle has ballooned past 500KB and Lighthouse scores are dropping.
  • An API endpoint that was fine at 100 requests per hour is now timing out at 10,000.
  • You have added Redis or Memcached but are not confident your cache invalidation strategy is correct.
  • A background job is consuming memory across its lifetime and the worker eventually crashes.
  • You are preparing for a traffic spike (product launch, press coverage) and want to pre-emptively tighten the stack.

Example output

Given application_type: Laravel REST API, symptoms: p95 response time 2.1s on /api/orders, tech_stack: Laravel 11, MySQL 8, Redis, caching_layer: Redis:

1. N+1 issue found in OrderController@index
   - Fix: eager load with ->with(['customer', 'items.product'])
   - Expected gain: ~60% query reduction, est. 800ms saved

2. Missing composite index on orders(user_id, created_at)
   - Fix: CREATE INDEX idx_user_created ON orders(user_id, created_at);
   - Expected gain: full-table scan to index scan, est. 400ms saved

3. Redis cache for /api/orders (per user, 60s TTL)
   - Fix: Cache::remember("orders:{$userId}", 60, fn() => ...)
   - Expected gain: cache-hit path drops to ~40ms

Pro tips

  • Fill [symptoms] with actual log output or profiler traces, not your guess. "Slow" is useless. "EXPLAIN shows 80K rows examined on the orders table" is actionable.
  • If your [tech_stack] includes an ORM (Eloquent, ActiveRecord, SQLAlchemy), name it explicitly — the AI will tailor N+1 detection to that ORM's syntax rather than raw SQL advice.
  • Run this prompt once per layer in isolation. One session for database, a separate session for frontend. Mixing all five areas in one response often produces shallow coverage of each.
  • After getting the fixes, paste the actual migration or code back into a follow-up message and ask ChatGPT to review it for correctness before deploying — it will catch index naming collisions and cache key collision risks.
  • Set realistic [target_metrics]. Asking for a 10x improvement on a well-tuned stack will skew the output toward impractical architectural rewrites. Incremental targets (e.g., p95 from 2.1s to 500ms) produce grounded, implementable suggestions.

Frequently Asked Questions

Does this prompt work if I don't have profiler data yet — just a feeling that the app is slow?
It works, but the output will be less precise. Fill [symptoms] with what you do know: which routes feel slow, what the server CPU or memory looks like, whether it worsens under load. The more concrete your input, the more targeted the fixes. If you have nothing, run Laravel Telescope, Blackfire, or even a basic EXPLAIN on your slowest queries first, then come back to the prompt.
Can I use this for a frontend-only app with no database layer?
Yes — just set [application_type] to something like 'React SPA' and [symptoms] to your Lighthouse scores or bundle sizes. Leave the database investigation area as 'N/A' or replace it with a different concern (e.g., third-party script load order). The prompt's five numbered areas are a starting framework, not a contract — ChatGPT will follow the structure you give it.
Will the 'expected improvement' figures the AI gives be accurate?
Treat them as directional estimates, not guarantees. ChatGPT reasons from patterns in its training data, not from profiling your actual database or runtime. They are useful for prioritization (fix the thing with the biggest estimated gain first) but always validate with a real before/after benchmark after implementing each change.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in ChatGPT Prompts for Developers

Engr Mejba Ahmed

Engr Mejba Ahmed

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

mejba.13@gmail.com

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support