I have some complex queries that are usually fast (< 1 sec), but occasionally slow (> 10 sec, even minutes).
How do I track this down or identify what condition is causing it?
One theory was caching – perhaps the query is fast when the blocks cached in memory. I tried flushing both the shared pool and the buffer cache (“alter system flush buffer_cache”) but the query is still fast after doing that.
Is there a way to nail down precisely what was going on during a specific execution that was bad, and which part of query execution took the longest?