These docs are a work-in-progress and are currently undergoing a major rewrite!
Forge Pro

Query stats

On each page, the query stats will display how many database queries were performed and how long they took.

Clicking the stats in the toolbar will show the full SQL query log with tracebacks and timings. This is even designed to work in production, making it much easier to discover and debug performance issues on production data!

Django query stats

It will also point out duplicate queries, which can typically be removed by using select_related, prefetch_related, or otherwise refactoring your code.

Installation

# settings.py
INSTALLED_APPS += [
    "forgepro.querystats",
]

MIDDLEWARE = MIDDLEWARE + [
    "forgepro.querystats.QueryStatsMiddleware",
    # Put QueryStats above additional middleware
    # ...
]