Technologies/MySQL/db.client.operation.duration
MySQLMySQLMetric

db.client.operation.duration

Database operation execution time
Dimensions:None

Technical Annotations (82)

Configuration Parameters (19)
iterator.chunk_sizerecommended: 500
batch size for processing annotated results without loading entire result set
pool_moderecommended: transaction
PgBouncer pooling mode - connection assigned per transaction then returned to pool
max_client_connrecommended: 500
Maximum number of client connections PgBouncer accepts
default_pool_sizerecommended: 25
Pool size should be 25-50% of PostgreSQL max_connections
server_idle_timeoutrecommended: 600
Seconds before idle server connection is closed
page_sizerecommended: 50
Default pagination size for list endpoints when client doesn't specify
statement_timeoutrecommended: 10000
PostgreSQL query timeout in milliseconds to kill runaway queries
DATABASES
Dictionary in settings.py containing database credentials and connection settings
DATABASES.default.ENGINErecommended: dj_db_conn_pool.backends.postgresql
pooling-aware backend required for connection pooling
DATABASES.default.CONN_MAX_AGErecommended: 0
let pool manage connections, not Django's per-request reuse
DATABASES.default.POOL_OPTIONS.POOL_SIZErecommended: 10
number of persistent connections in pool
DATABASES.default.POOL_OPTIONS.MAX_OVERFLOWrecommended: 5
extra connections allowed beyond pool size
CONN_MAX_AGErecommended: 0
Prevents persistent connections from timing out; set to 0 to disable connection pooling
wait_timeout
MySQL server-side timeout for idle connections; coordinate with CONN_MAX_AGE
duration_threshold_msrecommended: 100
Threshold for marking queries as slow in span attributes
transaction_duration_threshold_msrecommended: 1000
Threshold for slow transaction warning
NPLUSONE_DETECTOR.THRESHOLDrecommended: 5
Query repetition count before middleware reports potential N+1 issue
managerrecommended: FastCountManager
Replace default manager to enable count caching
django.db.backendsrecommended: DEBUG
Logger level for SQL query logging to detect N+1 patterns
Error Signatures (8)
timeout errorslog pattern
Connection pool exhaustedlog pattern
DatabaseErrorexception
no more connections allowed (max_client_conn)error code
query_wait_timeouterror code
connection failed: connection to server at "...", port 6432 failed: ERROR: no more connections allowed (max_client_conn)error code
OperationalError: MySQL server has gone awayexception
deadlockexception
CLI Commands (9)
python manage.py dbshelldiagnostic
EXPLAIN ANALYZEdiagnostic
SHOW PROCESSLISTdiagnostic
SELECT * FROM pg_stat_activitydiagnostic
from django.db import connection, reset_queries reset_queries() print(f"Total queries: {len(connection.queries)}")diagnostic
SHOW POOLSmonitoring
EXPLAIN ANALYZE SELECT * FROM orders ORDER BY created_at DESC LIMIT 50 OFFSET 0;diagnostic
CREATE INDEX idx_orders_created_at ON orders(created_at DESC);remediation
SELECT split_part(query, 'WHERE', 2) AS sql, COUNT(*) AS count FROM pg_stat_activity WHERE datname = '...' GROUP BY querydiagnostic
Technical References (46)
prefetch_relatedcomponentPrefetchcomponentSeq Scanconceptmodels.IndexcomponentDjango Debug Toolbarcomponentannotate()componentCountcomponentSumcomponentselect_related()componentprefetch_related()componentdjango-debug-toolbarcomponentPgBouncercomponentmax_connectionscomponent.iterator()componentserver-side cursorsconceptchunk_sizecomponentpaginationconceptORMcomponentorders modelcomponentOrder.objects.all()componentIndex Scanconceptsettings.pyfile pathdj_db_conn_poolcomponentpg_stat_activitycomponentDatabaseConnectionMiddlewarecomponentMIDDLEWAREcomponentCONN_MAX_AGEcomponentQuerySetcomponentTracedCursorWrappercomponentdb.slow_querycomponenttransaction.atomiccomponenttraced_atomiccomponentEXPLAINcomponentselect_relatedcomponentForeignKeycomponentQuerySet.count()componentFastCountManagercomponentDjango admincomponentFastCountQuerySetcomponentSQL joinconceptmany-to-many relationshipsconceptreverse foreign keyconceptSubquery()componentOuterRef()componentDjango REST FrameworkcomponentDATABASEScomponent
Related Insights (37)
Prefetch loads millions of related objects causing memory explosionwarning
Missing database indexes cause 30+ second query times in productionwarning
Django app consumes 100% CPU from infinite loops or full table scanscritical
Annotated querysets with aggregates load massive result sets into memorywarning
N+1 query pattern executes one query per object for related recordscritical
PostgreSQL connection count exceeds limits causing memory exhaustionwarning
Server-side cursors with iterator() hold long transactions causing lock contentionwarning
Unpaginated queries on large tables cause expensive operationswarning
Infrastructure-only monitoring misses Django application failureswarning
PostgreSQL query spike causing checkout latency during peak trafficcritical
N+1 query pattern degrading Django response timewarning
Unpaginated list endpoints cause outage at scalecritical
Missing index on ORDER BY column causes full table scan despite paginationwarning
Missing query timeout allows indefinite hangs and connection pool exhaustioncritical
DatabaseError during query or transaction operationscritical
Default Django backend causes connection overhead under loadwarning
Django connections remain idle indefinitely despite CONN_MAX_AGE settingcritical
MySQL connection timeout causes 'server has gone away' errors during traffic spikescritical
Django ORM generates duplicate queries causing high query counts per pagewarning
N+1 query problem multiplies database queries per itemwarning
Slow database queries exceed 100ms thresholdwarning
Transaction deadlocks cause transaction rollbackcritical
Long transactions exceed 1 second durationwarning
Unindexed queries perform full table scanswarning
Missing composite indexes on multi-criteria filterswarning
Excessive joins from deep select_related chainingwarning
Missing index on foreign keys in large tableswarning
N+1 queries cause exponential database load as data scaleswarning
Django QuerySet.count() becomes O(n) bottleneck on tables with millions of rowswarning
Django admin becomes unusable due to count() on every list page for large tablescritical
N+1 queries cause sluggish performance and scalability issueswarning
Foreign key access without select_related causes N+1 querieswarning
Many-to-many or reverse foreign key access causes N+1 querieswarning
Aggregating related data in loops causes N+1 querieswarning
Complex per-record calculations cause N+1 querieswarning
Per-request database connections cause API latency under loadwarning
Database bottleneck causes response time spikes during high trafficwarning