P95 Query Time
34 ms
Compared to previous 7 days
Query Responses
Click marker to copy SHA
| Time Period | Executions ▲ | Avg Duration | Min Duration | Max Duration |
|---|---|---|---|---|
| Nov 15, 2026 | 67 | 17.12 ms | 1.0 ms | 34.0 ms |
| Nov 20, 2026 | 67 | 16.97 ms | 1.0 ms | 34.0 ms |
| Nov 11, 2026 | 69 | 19.52 ms | 1.0 ms | 37.0 ms |
| Nov 17, 2026 | 70 | 19.01 ms | 1.0 ms | 35.0 ms |
| Nov 14, 2026 | 77 | 17.82 ms | 1.0 ms | 37.0 ms |
Total of 15 record(s).
Page 2 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 | — | 500 |
Raw Data
{
"query": {
"id": 7240,
"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-11-22 14:02:27 UTC"
},
"performance": {
"total_executions": 500,
"p95_duration_ms": "34.0",
"avg_duration_ms": 17.954,
"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": 500,
"p95_duration_ms": "34.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"
]
}