Operation 240052

SELECT * FROM posts WHERE user_id = ? ORDER BY created_at DESC LIMIT ?
Operation Type
sql
Duration
30.0 ms
Request Impact
300.0% of total request time
Occurred At
Sep 16, 2026 4:43 PM
SQL Analysis
Normal query (<100 ms)
Performance Comparison
Average: 17.9ms
95th Percentile: 34.0ms
Based on 1000 recent operations
Related Operations
2 similar operations in this request
Optimization Tips
Use includes() or preload() to load associated records - Eliminate N+1 queries and reduce database load
Use includes() to eager load associations - Eliminate N+1 queries and reduce database load
Use joins() when you only need to filter, not access associated data - Eliminate N+1 queries and reduce database load
Use preload() when you don't need to query on associations - Eliminate N+1 queries and reduce database load
Add composite index: add_index :posts, ["user_id", "created_at"] - Single index for filtering and sorting
Add single_column index: add_index :posts, :user_id - Fast lookups for user_id = value queries
Add single_column index: add_index :posts, :created_at - Avoid sorting for ORDER BY created_at
Specify only needed columns instead of SELECT * - Reduced memory usage and faster data transfer
Index Optimization - Review indexes on the 'posts' table. Consider composite indexes for WHERE clauses.