P95 Query Time
33 ms
Compared to previous 7 days
Query Responses
Click marker to copy SHA
| Time Period ▼ | Executions | Avg Duration | Min Duration | Max Duration |
|---|---|---|---|---|
| Sep 23, 2026 | 32 | 22.19 ms | 1.0 ms | 35.0 ms |
| Sep 22, 2026 | 78 | 19.14 ms | 2.0 ms | 35.0 ms |
| Sep 21, 2026 | 59 | 17.81 ms | 1.0 ms | 35.0 ms |
| Sep 20, 2026 | 71 | 18.38 ms | 1.0 ms | 35.0 ms |
| Sep 19, 2026 | 48 | 19.67 ms | 1.0 ms | 35.0 ms |
| Sep 18, 2026 | 51 | 19.02 ms | 1.0 ms | 35.0 ms |
| Sep 17, 2026 | 52 | 16.85 ms | 1.0 ms | 34.0 ms |
| Sep 16, 2026 | 75 | 17.05 ms | 1.0 ms | 35.0 ms |
| Sep 15, 2026 | 70 | 17.61 ms | 1.0 ms | 35.0 ms |
| Sep 14, 2026 | 62 | 15.31 ms | 1.0 ms | 43.0 ms |
Total of 15 record(s).
Page 1 of 2
Normalized Query
SELECT users.*, COUNT(DISTINCT posts.id) as post_count, COUNT(DISTINCT comments.id) as comment_count, SUM(posts.view_count) as total_views, AVG(posts.view_count) as avg_views, MIN(posts.created_at) as first_post, MAX(posts.created_at) as latest_post FROM users LEFT JOIN posts ON users.id = posts.user_id LEFT JOIN comments ON users.id = comments.user_id GROUP BY users.id
Diagnostics
Query Characteristics
- Query Type
- SELECT
- Tables
- 3
- Joins
- 2
- Complexity Score
- 12
- Has LIMIT
- No
- Has ORDER BY
- No
- Has GROUP BY
- Yes
- Has Subqueries
- No
Issues Detected
- SELECT query without WHERE clause may return excessive data
Optimization Suggestions
-
Add single_column index: add_index :comments, :user_id
— Fast JOIN execution
add_index :comments, :user_id -
Add single_column index: add_index :posts, :user_id
— Fast JOIN execution
add_index :posts, :user_id - Add WHERE clause to filter results — Avoid full table scans and reduce data transfer
Query Locations
| Location | P95 Duration (ms) | P95 Row Count | Count |
|---|---|---|---|
app/controllers/dashboard_controller.rb:78 |
34.0 | — | 499 |
app/jobs/webhook_delivery_job.rb:53 |
30.0 | — | 1 |
Raw Data
{
"query": {
"id": 180,
"normalized_sql": "SELECT users.*, COUNT(DISTINCT posts.id) as post_count, COUNT(DISTINCT comments.id) as comment_count, SUM(posts.view_count) as total_views, AVG(posts.view_count) as avg_views, MIN(posts.created_at) as first_post, MAX(posts.created_at) as latest_post FROM users LEFT JOIN posts ON users.id = posts.user_id LEFT JOIN comments ON users.id = comments.user_id GROUP BY users.id",
"analyzed_at": "2026-09-23 10:02:24 UTC"
},
"performance": {
"total_executions": 500,
"p95_duration_ms": "34.0",
"avg_duration_ms": 18.524,
"p95_row_count": null,
"avg_row_count": null
},
"characteristics": {
"query_type": "SELECT",
"table_count": 3,
"join_count": 2,
"where_clause_complexity": 0,
"has_subqueries": false,
"has_limit": false,
"has_order_by": false,
"has_group_by": true,
"has_having": false,
"has_distinct": true,
"has_aggregations": true,
"estimated_complexity": 12
},
"call_locations": [
{
"location": "app/controllers/dashboard_controller.rb:78",
"count": 499,
"p95_duration_ms": "34.0",
"p95_row_count": null
},
{
"location": "app/jobs/webhook_delivery_job.rb:53",
"count": 1,
"p95_duration_ms": "30.0",
"p95_row_count": null
}
],
"n_plus_one": {
"detected": false
},
"index_recommendations": [
"add_index :posts, :user_id",
"add_index :comments, :user_id"
],
"issues": [
"SELECT query without WHERE clause may return excessive data"
]
}