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