{% with messages = get_flashed_messages(with_categories=true) %} {% if messages %} {% for category, message in messages %}
{{ message }}
{% endfor %} {% endif %} {% endwith %}

Query Details

Back to Queries

Query #{{ query_id + 1 }}

Calls

{{ query.calls }}

Total Time

{{ "%.2f"|format(query.total_time) }} ms

Mean Time

{{ "%.2f"|format(query.mean_time) }} ms

Rows

{{ query.rows }}

SQL Query
{{ query.query }}
I/O Statistics
Shared blocks hit: {{ query.shared_blks_hit }}
Shared blocks read: {{ query.shared_blks_read }}
Temp blocks written: {{ query.temp_blks_written }}
I/O Time: {{ "%.2f"|format(query.io_time) }} ms
I/O Percentage: {{ "%.2f"|format(query.io_percentage) }}%
Performance Metrics
Time per row: {{ "%.4f"|format(query.time_per_row) }} ms
Rows per second: {{ "%.2f"|format(1000 / query.time_per_row) if query.time_per_row > 0 else "N/A" }}
Total execution cost: {{ "%.2f"|format(query.total_time) }} ms ({{ "%.2f"|format(query.total_time / 1000) }} seconds)
Cache hit ratio: {% set total_blocks = query.shared_blks_hit + query.shared_blks_read %} {% if total_blocks > 0 %} {{ "%.2f"|format((query.shared_blks_hit / total_blocks) * 100) }}% {% else %} N/A {% endif %}

Optimization Recommendations

Performance Analysis
    {% if query.io_percentage > 50 %}
  • This query is I/O-bound ({{ "%.2f"|format(query.io_percentage) }}% of time spent on I/O)
  • Consider adding indexes or optimizing data access patterns
  • {% else %}
  • This query is CPU-bound ({{ "%.2f"|format(100 - query.io_percentage) }}% of time spent on processing)
  • Look for complex calculations or functions that could be optimized
  • {% endif %} {% if query.temp_blks_written > 0 %}
  • Query writes temporary blocks to disk, which can slow performance
  • Consider increasing work_mem to reduce disk writes
  • {% endif %} {% if query.time_per_row > 1.0 %}
  • Time per row is high ({{ "%.4f"|format(query.time_per_row) }} ms)
  • Consider optimizing WHERE conditions or adding indexes
  • {% endif %}
Next Steps
  • Run EXPLAIN ANALYZE on this query to see the execution plan
  • Check if all tables in the query have appropriate indexes
  • Consider rewriting complex JOINs or subqueries
  • Review the data lineage graph to understand table relationships