Operation 119479

SELECT * FROM comments WHERE post_id = ? ORDER BY created_at DESC LIMIT ?
Operation Type
sql
Duration
28.0 ms
Request Impact
58.2% of total request time
Occurred At
Sep 10, 2026 3:31 PM
SQL Analysis
Normal query (<100 ms)
Performance Comparison
Average: 18.2ms
95th Percentile: 34.0ms
Based on 1000 recent operations
Optimization Tips
Add composite index: add_index :comments, ["post_id", "created_at"] - Single index for filtering and sorting
Add single_column index: add_index :comments, :post_id - Fast lookups for post_id = value queries
Add single_column index: add_index :comments, :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 'comments' table. Consider composite indexes for WHERE clauses.