|
|
|
|
|
by n0tme
2481 days ago
|
|
I am talking about INDEX FAST FULL SCAN (Oracle) for example. If you do 'select distinct last_name from users;' and you have an index on users (last_name) you do not need to read the table at all. It is enough to read the index. Otherwise it does not matter how many columns you select, because you will have to read all the columns for every row anyway. |
|
It does matter. An index can actually contain a cache of values for some columns. This is done with INCLUDE statement.
This select will use only index: This select will use index, and then have to follow and fetch data out of rows: https://use-the-index-luke.com/blog/2019-04/include-columns-...