Why is the full table scan COST (COST) divided by sreadtim and costsreadtim?
The cost of full table scan is calculated as follows:
Cost = ( #SRds * sreadtim + #MRds * mreadtim + CPUCycles / cpuspeed ) / sreadtim
During full table scan, the number of reads per block is 0, and # SRds indicates the number of reads per block. In the cost of full table scan, the CPU consumption is actually very small and negligible. Therefore, the formula for full table scan can be rewritten:
Cost = #MRds * mreadtim / sreadtim
# MRds indicates the number of multi-block read io times
Mreadtim indicates that it takes time to read multiple data blocks at a time.
Sreadtim indicates that it takes time to read a single block.
The full table scan COST means actually multiple read io times * multiple read times/single read time
So why should we divide the full table scan cost formula by sreadtim? Let's take a look at the index scan cost calculation formula:
cost = blevel + celiling(leaf_blocks *effective index selectivity) + celiling(clustering_factor * effective table selectivity)
Blevel is the root-to-branch of the index scanning --- single-block read
Celiling (leaf_blocks * Valid tive index selectiing) is the number of scanned blocks-single block read
Ceiling (clustering_factor * Valid tive table selectivity) is the number of times the table is returned through the indexed rowid-single block read
The essence of the cost formula for index scanning is actually the number of I/O reads per block.
For single-Table Access (what is single-Table access? Select only one table), either full table scan or index scan, but also materialized view (this is not considered)
Does ORACLE perform full table scan or index scan? It is the COST used to calculate full table scans, and the COST used to calculate index scans can be used to calculate which COST consumes less.
The question is, why can ORACLE computing COST accurately determine which one is the best? Now let's compare the COST of full table scan and the COST of index scan.
Full table scan COSTMulti-block read io count * multi-block read time/Single-block read time
Index scan COST read io count per block
So now we all scan the entire table COST, both scan the index COST multiplied by a single read time
Full table scan COST * single block read time = multiple block read io times * multiple block read time = total consumed time
Index scan COST * single block read time = single block read io count * single block read time = total consumed time
To put it bluntly, it is to select the full table scan and index scan who takes the least time.
You should have understood it here. I have to admire the minds of ORACLE designers.
Why is the opportunity cost formula divided by 2?
Opportunity Cost = C/2 * K
C is the amount of cash held, and the amount of cash held by these companies is constantly flowing out. When the outflow amount reaches 0, the amount of cash held by C needs to be obtained again. C → 0, C → 0... The average cash holdings are C/2.
Formula of Consumption Tax Group price: (cost + profit) ÷ (1-consumption tax ratio) What is this formula? Why divide by 1-proportional tax rate
The derivation process is as follows:
Tax calculation price = Cost + profit + Consumption Tax
Consumption Tax Amount = taxable price * Consumption Tax Rate
Merge two formulas:
Tax calculation price = Cost + profit + tax calculation price * Consumption Tax Rate
So: tax price-tax price * consumption tax rate = Cost + profit
Tax calculation price * (1-consumption tax rate) = Cost + profit
Tax calculation price = (cost + profit) (1-consumption tax rate)