Based on your test with the cache buffer chain contention I assume the wait
events for that query wouldn't show much (if any) time spent actually waiting
on cache buffer chain latching- the CPU time is higher than elapsed time so
there isn't any time waiting on anything. correct - unless the contention was so severe that I spun more than 2000 times - there would be NO waits - just misses on the latch.
Assuming a trace didn't show the cache buffer chain latching how would I know
the higher CPU time in that trace was in fact due to extra spinning in the
cache buffer chain latching?you wouldn't see it in a trace, you would only see it at the "system" level and it would be visible via a high number of "latch misses"
Get Spin
Latch Name Requests Misses Sleeps Gets
-------------------------- --------------- ------------ ----------- -----------
cache buffers chains 2,474,493 3,313 79 3,237
shared pool 39,878 67 20 54
row cache objects 66,057 24 3 21
-------------------------------------------------------------
you'd see something like that in your statspack/awr reports (that is from my example above). As spin gets go up, so goes your CPU
Are there other scenraios where the same query does the same logical/physical
reads yet one consumes more CPU than the other that are not due to cache buffer
chain latching? sure, you might take a query like:
hash join
full scan t1
full scan t2
and turn it into
nested loop
table access by index rowid
index range scan
table access by index rowid
index range scan
and find the cpu to be less in #2 even if the IO's are more (particularly in single user mode). The reason:
o hash join is more cpu intensive than nested loop in general. We have to hash all of the values we get from T1 into memory/temp and then do the hash lookup from t2 into t1. Hashing can be a cpu intensive sort of operation
o we probably evaluate some predicate more often in case #1, just like your example above
There are other examples too - not all logical IO's are 'equal', some are cheaper than others - there are reads from undo for read consistency - they can be "cheaper" than a read from a table. There are new "fastpath" consistent gets. You might have to process delayed block cleanouts for one query and not for another (by hitting different sets of blocks - or by hitting the same block over and over and over again instead of hitting all of the blocks in the table).