Algorithm - Cost (Performance Metrics) in relational operation.
The cost is an estimated value proportional to the expected resource use needed to execute the statement with a particular execution_plan. The plan estimator calculates the cost of access paths and join orders based on the estimated computer resources, which includes I/O, CPU, and memory.
Serial plans with higher costs take more time to execute than those with smaller costs. When using a parallel plan, however, resource use is not directly related to elapsed time.
The cost represents units of resource used (I/O, CPU, memory).
The query optimizer uses disk I/O, CPU usage, and memory usage as units of work. So, the cost used by the query optimizer represents an estimate of the number of disk I/Os and the amount of CPU and memory used in performing an operation.
The operation can be :
The cost of a query plan is the number of work units that are expected to be incurred when the query is executed and its result produced.
The access path determines the number of units of work required to get data from a base table.
The access path can be :
During table scan or fast full index scan, multiple blocks are read from the disk in a single I/O operation. Therefore, the cost of a table scan or a fast full index scan depends on the number of blocks to be scanned and the multiblock read count value.
The cost of an index scan depends on the levels in the B-tree, the number of index leaf blocks to be scanned, and the number of rows to be fetched using the rowid in the index keys.
The cost of fetching rows using rowids depends on the index clustering factor.
The join cost represents the combination of :
The optimizer estimates costs in the following ways:
The optimizer also considers other factors when determining the cost of each operation. For example: