I have a general question about something I'm seeing in performance tuning in Oracle. I have a query that I'm testing. It's too big and complex for me to provide a simple example, sorry! (I tried lowering it down, but lost the symptom)
The first time I run the query, it's 2 seconds. Subsequent times it's 3, 4, or even 5 seconds. This happens consistently - if I change the spacing, I get 2 seconds again, then it goes back up.
This is the opposite of what I would expect - after the first time, the database doesn't need to parse the query, and blocks should be in read into the buffer cache. The only thing I can think of is that it is writing temp data somewhere, in such a way that it is faster to write and read it than it is to just read it. But that of course makes no sense.
Does anyone know why this is happening? Or any red flags in the execution plan that would cause something like this?
FYI, this is a SELECT, with multiple joins, aggregation, and views. No internal PL/SQL.
@Colin It's unlikely another process could be affecting this Dev machine, at least so consistently. Not sure what dynamic sampling is. Same thing as cardinality feedback?
@druzin No bind variables, but no predicate changes either - same hash.
@mustaccio Good idea, although I suspect it's something to do with implicit temp tables or caching. I'll give it a try.