How can I calculate the cost of the query, if there is a between condition?
Select *
From A
Where A.id between 10 and 50
If Index not exists and there is only one condition:
- Search in B+ tree to find the first block that meets the condition (Binary search).
Cost:
log_2(b_A). Search in the following blocks that meets the condition. (Suppose half of the blocks meet the condition). Cost:
b_A/2.If the condition was
Where A.id > 10, then the cost would be:log_2(b_A) + b_A/2If the condition was
Where A.id < 50, then the cost would be:log_2(b_A) + b_A/2
What is the correct way to calculate cost of 2 ranges of the same field?