Selection

What
A selection operation is the process of finding all the tuples in a relation that match the selection condition.

Considerations

 * 1) What access paths/indexes are available
 * 2) What is the expected size of the result

Non-Indexed and Unsorted
In this case, the cost of selection is the entire table $$M$$

Non-Indexed and Sorted
In this case, the cost of selection is $$log _2 M + \lceil \textrm{selectivity} * M \rceil$$. That is, we must perform a binary search and then read the number of pages we need based on the selection condition.

Indexed
When the file is indexed, we can use the index to find the records that are consistent with the selection condition.

Most Selective Access Path Approach
This approach to implementing general selection is done like so:
 * 1) Pick the most selective access path and retrieve tuples from the table using it
 * 2) Use the remaining attributes that are not part of the index to filter the results

Example
Consider the query:

day < 8/9/94 AND bid=5 AND sid=3

Given a B Tree index on day, this approach tells us to use the index on day to find all qualifying tuples then use the remaining conditions on bid and sid to filter the results to arrive at the final answer.