Monday, August 30, 2010

What IS the cost of a query and what does it mean?

The formula for the cost (using the CPU Costing Model) of a query is:

Cost = (
#SRds * sreadtime
+ #MRds * mreadtime
+ #CPUCycles / cpuspeed
) / sreadtime

where:
#SRds = number of single block reads
#MRds = number of multi block reads
#CPUCycles = number of CPU Cycles

sreadtim = single block read time
mreadtime = multi block read time
cpuspeed = Standard 'Oracle' CPU cycles per second

The translation of this formula is:

The cost is the time spent on single block reads, plus the time spent on multiblock reads, plus the CPU time required, all divided by the time is takes to do a single block read.

This means that the cost of a query is the PREDICTED EXECUTION TIME, counted in number of single block read times and is effectively the unit of measure of the cost.

Monday, August 23, 2010

How do you find the invalid objects in your schema?

SELECT   object_name,
         object_type,
         created,
         last_ddl_time,
         status
  FROM   user_objects
 WHERE   status != 'VALID'