Operation 226295

SELECT * FROM users LEFT JOIN posts ON users.id = posts.user_id LEFT JOIN comments ON posts.id = comments.post_id LEFT JOIN tags ON posts.id = tags.post_id LEFT JOIN categories ON posts.category_id = categories.id WHERE users.active = ? AND posts.published = ? AND comments.approved = ? AND tags.name LIKE ? AND categories.visible = ? AND users.email LIKE ? AND posts.title LIKE ? OR comments.content LIKE ? AND users.created_at BETWEEN ? AND ? AND posts.updated_at > ? ORDER BY users.created_at, posts.created_at, comments.created_at
Operation Type
sql
Duration
8.0 ms
Request Impact
2.4% of total request time
Occurred At
Sep 18, 2026 12:59 AM
SQL Analysis
Normal query (<100 ms)
Performance Comparison
Average: 17.9ms
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", "visible", "created_at", "updated_at", "name", "email", "title", "content", "created_at", "created_at", "created_at"] - Single index for filtering and sorting
Add composite index: add_index :users, ["active", "published", "approved", "visible", "created_at", "updated_at", "name", "email", "title", "content"] - Efficient multi-column filtering
Add single_column index: add_index :comments, :post_id - Fast JOIN execution
Add single_column index: add_index :posts, :category_id - Fast JOIN execution
Add single_column index: add_index :posts, :user_id - Fast JOIN execution
Add single_column index: add_index :tags, :post_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, :visible - Fast lookups for visible = value queries
Add composite index: add_index :users, ["created_at", "created_at", "created_at"] - Avoid sorting for complex ORDER BY
Add single_column index: add_index :users, :created_at - Efficient range scans for created_at
Add single_column index: add_index :users, :updated_at - Efficient range scans for updated_at
Review if all 4 JOINs are necessary - Simplified query execution and better performance
Specify only needed columns instead of SELECT * - Reduced memory usage and faster data transfer
Consider breaking complex query (complexity: 33) into smaller parts - Easier maintenance and potentially better performance
Simplify WHERE clause by breaking into multiple queries or using views - Easier maintenance and potentially better performance
Index Optimization - Review indexes on the 'users' table. Consider composite indexes for WHERE clauses.