Operation 100671

SELECT users.* FROM users LEFT JOIN posts ON users.id = posts.user_id LEFT JOIN comments ON posts.id = comments.post_id WHERE users.active = ? AND posts.published = ? AND comments.approved = ? OR users.created_at > ? AND posts.created_at > ? AND comments.created_at > ?
Operation Type
sql
Duration
15.0 ms
Request Impact
2.6% of total request time
Occurred At
Sep 14, 2026 8:22 AM
SQL Analysis
Normal query (<100 ms)
Performance Comparison
Average: 18.0ms
95th Percentile: 34.0ms
Based on 1000 recent operations
Related Operations
5 similar operations in this request
Potential N+1 query pattern detected
Optimization Tips
Add composite index: add_index :users, ["active", "published", "approved", "created_at"] - Efficient multi-column filtering
Add single_column index: add_index :comments, :post_id - Fast JOIN execution
Add single_column index: add_index :posts, :user_id - Fast JOIN execution
Add single_column index: add_index :users, :active - Fast lookups for active = value queries
Add single_column index: add_index :users, :approved - Fast lookups for approved = value queries
Add single_column index: add_index :users, :published - Fast lookups for published = value queries
Add single_column index: add_index :users, :created_at - Efficient range scans for created_at
Consider breaking complex query (complexity: 18) into smaller parts - Easier maintenance and potentially better performance
Index Optimization - Review indexes on the 'users' table. Consider composite indexes for WHERE clauses.