Krit, It sounds like you might be hitting edge-case statistics problems on recent data. We’ve had issues with this before, ourselves. I’d personally recommend increasing your default_statistics_target to 400 for your entire database in general.
But it’s possible that won’t help this. Recent data tends to have no stats at all, and if it comes in with enough volume, the planner will be wrong a good majority of the time. If that’s the data you’re trying to grab, well… Based on that, you might want to consider tweaking your autovacuum_analyze_scale_factor setting so you get relatively frequent automatic analyzes so the stats are better through the day. Otherwise, your approach should work just fine. Good luck! See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email |