You’ve added the INDEXes, both partial and covering. You’ve VACCUUM ANALYZEd. You JOINed and INNER JOINed everything to a single query. And yet, your report is still taking too long. What do you do when the low-hanging fruit has been harvested? It’s time to get down and dirty with some of the lesser known SQL constructs in Rails land. EXPLAIN what’s happening If you’ve gotten this far, you’re prob