Discussion of Projection
Sort-based approach features better handling of skew and result is sorted.
Hash-based approach can be faster (locally).
If an index on the relation contains all wanted attributes in its search key, can do index-only scan.
- Apply projection techniques to data entries (much smaller!)
If an ordered (i.e., tree) index contains all wanted attributes as prefix of search key, can do even better:
- Retrieve data entries in order (index-only scan), discard unwanted fields, compare adjacent tuples to check for duplicates.