Operation 146707
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
- Operation Type
sql
- Duration
- 31.0 ms
- Request Impact
- 38.7% of total request time
- Occurred At
- Sep 16, 2026 7:38 AM
- SQL Analysis
- Normal query (<100 ms)
- Performance Comparison
-
Average: 18.2ms
95th Percentile: 34.0ms
Based on 1000 recent operations - Related Operations
-
4 similar operations in this request
Potential N+1 query pattern detected - Optimization Tips
-
Add single_column index: add_index :comments, :user_id - Fast JOIN executionAdd single_column index: add_index :posts, :user_id - Fast JOIN executionAdd WHERE clause to filter results - Avoid full table scans and reduce data transferConsider breaking complex query (complexity: 12) into smaller parts - Easier maintenance and potentially better performanceIndex Optimization - Review indexes on the 'users' table. Consider composite indexes for WHERE clauses.