Added a column to the debug view of sql queries which indicate whether a query originated in view code or template rendering.
- Legacy-Id: 12217
This commit is contained in:
parent
5c6f0c748b
commit
681395ff8e
ietf
|
@ -11,3 +11,13 @@ def rfcdiff_base_url(request):
|
|||
|
||||
def revision_info(request):
|
||||
return {'revision_time': __date__[7:32], 'revision_date': __date__[7:17], 'revision_num': __rev__[6:-2], "revision_id": __id__[5:-2], "version_num": __version__+__patch__ }
|
||||
|
||||
def debug_mark_queries_from_view(request):
|
||||
"Marks the queries which has occurred so far as coming from a view."
|
||||
context_extras = {}
|
||||
if settings.DEBUG and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
|
||||
from django.db import connection
|
||||
for query in connection.queries:
|
||||
query['where'] = 'V' # V is for 'view'
|
||||
return context_extras
|
||||
|
||||
|
|
|
@ -253,6 +253,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
|||
'django.core.context_processors.media',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'ietf.context_processors.server_mode',
|
||||
'ietf.context_processors.debug_mark_queries_from_view',
|
||||
'ietf.context_processors.revision_info',
|
||||
'ietf.secr.context_processors.secr_revision_info',
|
||||
'ietf.context_processors.rfcdiff_base_url',
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<th data-header="sequence">#</th>
|
||||
<th data-header="query">SQL</th>
|
||||
<th data-header="count">Count</th>
|
||||
<th data-header="where">Where</th>
|
||||
<th data-header="time">Time</th>
|
||||
<th data-header="acc">Acc.</th>
|
||||
</tr>
|
||||
|
@ -30,6 +31,7 @@
|
|||
<td>{{ forloop.counter }}</td>
|
||||
<td>{{ query.sql|expand_comma|escape }}</td>
|
||||
<td>{{ query.count }}</td>
|
||||
<td>{{ query.where }}</td>
|
||||
<td>{{ query.time }}</td>
|
||||
<td>{{ query.time_accum }}</td>
|
||||
</tr>
|
||||
|
|
|
@ -33,6 +33,8 @@ def annotate_sql_queries(queries):
|
|||
timeacc[sql] = 0.0;
|
||||
timeacc[sql] += float(q['time'])
|
||||
for q in queries:
|
||||
if q.get('where', None) == None:
|
||||
q['where'] = 'T' # template
|
||||
sql = q['sql']
|
||||
q['count'] = str(counts[sql])
|
||||
q['time_accum'] = "%4.3f" % timeacc[sql]
|
||||
|
|
Loading…
Reference in a new issue