Django DB Performance
SkillDatabases & dataDiagnose and improve slow Django database-backed endpoints with evidence-first profiling, query-plan review, index selection, ORM loading fixes, batching, database-side computation, materialized views, and pagination choices. Use when a Django view, API, job, report, queryset, or database query is slow and the right optimization path is not obvious.
Use Django DB Performance in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add Django DB Performance and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the Django DB Performance skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; Ahel provides instructions and does not run this skill.
No other account needed.
Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
What this skill tells your AI
The instructions your AI receives, as published by hashgraph-online/awesome-codex-plugins in plugins/LVTD-LLC/skills/skills/django-db-performance/SKILL.md and read by Ahel’s review.
Use this as the orchestration skill for Django database performance work. Start with measured evidence, reproduce the slow path, and route to the smallest optimization that changes the measured bottleneck.
Core Workflow
-
Capture the symptom.
- Identify the exact endpoint, command, task, report, or queryset.
- Record current wall-clock time, query count, slow SQL, database backend, data volume, and Django version.
- Keep the original request parameters or fixture that reproduces the issue.
-
Profile before changing code.
- Use APM traces, database slow-query logs, Django Debug Toolbar,
connection.queries, or targeted logging. - If the expensive query is known, use
QuerySet.explain()or databaseEXPLAIN. - For API endpoints, profile serializers and permission checks as well as querysets.
- Use APM traces, database slow-query logs, Django Debug Toolbar,
-
Classify the dominant problem.
- Many repeated similar queries: use
django-orm-query-optimization. - One or two expensive SQL statements: use
django-query-plan-readinganddjango-index-design. - Large memory use or long loops over querysets: use
django-queryset-batch-processing. - Python loops computing counts, totals, flags, or latest related rows: use
django-db-side-computation. - Slow aggregate/report query that is acceptable when stale: use
django-materialized-views. - Slow or inconsistent list pages: use
django-pagination-performance. - Unclear evidence: use
django-query-profiling.
- Many repeated similar queries: use
-
Apply one change at a time.
- Prefer the narrowest change with a clear expected effect.
- Avoid adding indexes, prefetches, or materialized views speculatively.
- Confirm that the optimization helps real production-like data, not only tiny fixtures.
-
Verify and document the result.
- Re-run the same request or command with the same parameters.
- Compare query count, total DB time, wall-clock time, memory, and query plan.
- Keep before/after evidence in the PR or final report.
See diagnostic-flow.md for routing checklists, common symptoms, and before/after evidence templates.
Modern Django Notes
- Prefer
QuerySet.explain()for ORM query plans before dropping to rawEXPLAIN. - Prefer native Django/PostgreSQL migration operations such as
AddIndexConcurrentlyover hand-written concurrent index SQL when they fit. - Prefer ORM expressions,
Subquery,Exists,Window,GeneratedField, anddb_defaultwhen they make database work explicit and portable enough. - Treat every backend-specific optimization as conditional on the project database. PostgreSQL patterns do not automatically apply to MySQL, MariaDB, SQLite, or Oracle.
Verification
- Show the slow path is still functionally correct.
- Show the measured bottleneck improved.
- Show the optimization did not create a worse query, stale data bug, write-path regression, or memory spike.
Signals
- GitHub stars
- 1k
- Forks
- 316
- Last commit
- Oct 2026
Advanced
- Item type
- skill
- Key
django-db-performance- Source
- github.com/hashgraph-online/awesome-codex-plugins
github.com/hashgraph-online/awesome-codex-plugins
Related picks
Skill · wshobson
The pick for Pythonpython-pro
Skill · jeffallan
The pick for Pythondjango-targeted-mocking
Skill · hashgraph-online
The pick for Djangointegration-django
Skill · posthog
The pick for Djangomysql-patterns
Skill · affaan-m
The pick for MySQLmysql-query
Skill · hashgraph-online
The pick for MySQL