Legend and Symbols Before diving into the formulas, it's essential to understand the…
- User
Legend and Symbols Before diving into the formulas, it's essential to understand the symbols and terms used: Symbol Description NKeys(Col) The number of distinct values in column Col. High(Col) The highest value in column Col. Low(Col) The lowest value in column Col. NTuples(R) The number of tuples (rows) in relation (table) R. NPages(R) The number of pages required to store relation R. NPages(I) The number of pages used by index I. Height(I) The height of index I (number of levels in a B-tree index). Π RFi The product of all reduction factors RFi applied in a query. Π NTuples(Ri) The product of the number of tuples in all relations Ri participating in a join operation. num_passes(R) The number of passes required to sort relation R. PF Projection Factor: The portion (fraction) of all columns retained after a projection operation.
Reduction Factor (Selectivity) Reduction Factor (RF) quantifies the fraction of data remaining after applying a selection predicate. It estimates how much a query reduces the data size based on certain conditions. a. Selection: Column Equals a Value (Col = value) [ \text{RF} = \frac{1}{\text{NKeys(Col)}} ] • Explanation: Assumes uniform distribution of values. If a column has NKeys(Col) distinct values, selecting a specific value reduces the data to 1/NKeys(Col) of the original.b. Selection: Column Greater Than a Value (Col > value) [ \text{RF} = \frac{\text{High(Col)} - \text{value}}{\text{High(Col)} - \text{Low(Col)}} ] • Explanation: Proportion of data where the column's value is greater than the specified value, based on the column's range. c. Selection: Column Less Than a Value (Col < value) [ \text{RF} = \frac{\text{value} - \text{Low(Col)}}{\text{High(Col)} - \text{Low(Col)}} ] • Explanation: Proportion of data where the column's value is less than the specified value. d. Join: Column Equality (Col_A = Col_B) [ \text{RF} = \frac{1}{\max(\text{NKeys(Col_A)}, \text{NKeys(Col_B)})} ] • Explanation: For joining two tables on columns Col_A and Col_B, the reduction factor depends on the higher number of distinct keys in either column. e. No Information Available [ \text{RF} = \frac{1}{10} ] • Explanation: When there's no statistical information about the data distribution, a default "magic number" of 0.1 (1/10) is used as an estimate.
Result Size Calculations Estimates the number of tuples resulting from query operations. a. Single Table Query [ \text{Result_size} = \text{NTuples(R)} \times \prod \text{RFi} ] • Explanation: The number of tuples after applying one or more selection predicates with reduction factors RFi.b. Join Operations [ \text{Result_size} = \prod \text{NTuples(Ri)} \times \prod \text{RFi} ] • Explanation: For joining multiple relations, multiply the number of tuples in each participating relation and apply the combined reduction factors.
Indexing Cost Evaluates the cost of using different types of indexes to execute queries. a. B+-Tree Index i. Single Tuple Selection (Primary Key Lookup) [ \text{Cost} = \text{Height(I)} + 1 ] • Explanation: The cost includes traversing the index tree (height) and accessing the data page containing the tuple. - Assistant