Files
eth-summaries/semester4/dmdb/parts/04_query-processing/01_selection/01_index-scan.tex
T

23 lines
1.5 KiB
TeX

\subsubsection{Index Scan}
\begin{itemize}
\item \bi{Hash Index}: {\color{ForestGreen} $\tco{1}$, we read the bucket and possibly the overflow buckets.} {\color{red} Can only be used for equality predicates}
\item \bi{B+ Tree Index}: $\tco{\log_F(N) + X}$, with $F$ fanout, $N$ the number of leaf nodes and $X$ the ratio of number of selected tuples and tuples per page.
{\color{red} $X$ can be up to 1 per selected tuple with an unclustered index}. Optimization: we could sort the RIDs.
\item \bi{Bitmap Index}: $\tco{\text{size of bitmap index}} + X$, {\color{red} $X$ depends on clustering again}
\end{itemize}
The I/O cost for B+ Tree Index Scan is \cost{$\texttt{tree height} + \texttt{\#leaf pages} + \texttt{\#file pages}$}
\inlineexample{Computation example}
Given a relation $R$ with $N =$ one million records. There are 100 records on a page and we have a B+ Tree with the data entries $<k, rid>$
and it has a capacity of 500 data entries on each leaf. It also has 3 internal node levels and a fill factor of $0.67$.
Then the cost is computed as follows:
\begin{itemize}
\item 3 internal nodes to parse, $\ceil{\log_F(N)}$
\item Number of result records = $1,000,000 * 1\% = 10,000$ (this is the selectivity)
\item Number of leaf pages pointing to the results records = $10,000 / (500 \cdot 0.67) = 30$
\item Number of pages in the heap file that hold the result records $= 10,000 / 100 = 30$
\end{itemize}
Then, the total cost is $3 + 30 + 100 = 133$