{% extends "base.html" %} {% block title %}Query Inspector{% endblock %} {% block breadcrumb %}Query Inspector{% endblock %} {% block content %} {# ═══════════════════════════════════════════════════════════════════ AQUILIA ADMIN — LIVE QUERY INSPECTOR SQL Profiling · EXPLAIN Plans · N+1 Detection · ORM→SQL Translation ═══════════════════════════════════════════════════════════════════ #}

Live Query Inspector

Real-time database query profiling, EXPLAIN plans, and N+1 detection

{# ═══ METRIC CARDS ═══ #}
0
Total Queries
{{ queries_per_second }} q/s average
{{ "%.2f"|format(avg_duration) }}
Avg Duration
milliseconds
0
Slow Queries
> {{ slow_threshold_ms }}ms threshold
0
N+1 Detected
Duplicate query patterns
{# ═══ OPERATION BREAKDOWN ═══ #} {% if by_operation %}
Query Breakdown
{% for op, count in by_operation.items() %}
{{ count }}
{{ op }}
{% endfor %}
{% endif %} {# ═══ N+1 DETECTIONS ═══ #} {% if n1_list and n1_list|length > 0 %}
N+1 Query Patterns Detected
{% for n1 in n1_list %} {% endfor %}
SQL Pattern Count Model Total Time
{{ n1.pattern_sql|truncate(120) }} {% if n1.source %}
{{ n1.source }}
{% endif %}
{{ n1.count }}× {{ n1.model or '—' }} {{ "%.2f"|format(n1.total_duration_ms) }}ms
{% endif %} {# ═══ SLOW QUERIES ═══ #} {% if slow_query_list and slow_query_list|length > 0 %}
Slow Queries
{% for q in slow_query_list[:15] %} {% endfor %}
SQL Operation Model Duration Time
{{ q.sql|truncate(150) }} {% if q.params %}
Params: {{ q.params|truncate(80) }}
{% endif %}
{{ q.operation }} {{ q.model or '—' }} {{ "%.2f"|format(q.duration_ms) }}ms {{ q.timestamp[:19] if q.timestamp else '—' }}
{% endif %} {# ═══ RECENT QUERIES ═══ #}
Recent Queries {% if qi_total > 0 %} Showing {{ ((qi_page - 1) * qi_per_page) + 1 }}–{{ [qi_page * qi_per_page, qi_total]|min }} of {{ qi_total }} {% endif %}
{% if recent_queries and recent_queries|length > 0 %} {% for q in recent_queries %} {% endfor %}
ID SQL Op Duration Rows
{{ q.id }} {{ q.sql|truncate(120) }} {{ q.operation }} {{ "%.2f"|format(q.duration_ms) }}ms {{ q.rows_affected }}
{# ── Pagination Controls ── #} {% if qi_total_pages > 1 %}
{% if qi_page > 1 %} « {% else %} « {% endif %} {% set page_start = [1, qi_page - 2]|max %} {% set page_end = [qi_total_pages, qi_page + 2]|min %} {% if page_start > 1 %} 1 {% if page_start > 2 %} {% endif %} {% endif %} {% for p in range(page_start, page_end + 1) %} {% if p == qi_page %} {{ p }} {% else %} {{ p }} {% endif %} {% endfor %} {% if page_end < qi_total_pages %} {% if page_end < qi_total_pages - 1 %} {% endif %} {{ qi_total_pages }} {% endif %} {% if qi_page < qi_total_pages %} » {% else %} » {% endif %}
{% endif %} {% else %}

No queries captured yet

Queries will appear here as your application executes database operations.

{% endif %}
{# ═══ PER-MODEL BREAKDOWN ═══ #} {% if by_model and by_model|length > 0 %}
Queries by Model
{% for model, count in by_model.items() %}
{{ model }}
{{ count }} queries
{% endfor %}
{% endif %} {# ═══ AUTO-REFRESH ═══ #} {% endblock %}