Let's assume that I have a table with 30-50 millions records. It has ~40 columns. Currently when I request data it always requests all columns because of legacy ORM that we use.
I know that if we specify fewer result columns in
SELECT query, then it will be easier for SQL Server as it doesn't need to load them from disk and return to client. But what about SQL Server buffer cache?
Lets say my application executes such query:
SELECT Column1,Column2,...,Column40 FROM ... WHERE OwnerID = 42
So it will load all columns for these records, cache them in memory, and return to client.
And next query after it will be
SELECT Column1,Column2 FROM ... WHERE OwnerID = 42
So it won't load other columns and return much less data, but will it matter if anyway they are loaded from cache and not from disk, as we loaded all columns in previous query. Will it help SQL Server or it won't matter at all because of SQL cache? How much will be difference in terms of complexity for SQL Server?
I can't remove first query for now, so I'm trying to optimize next queries for the same entity and trying to figure out a good ways.