Don't select unnecessary columns
See original GitHub issuebool b = false;
var q = from t in db.Tbl1
select new
{
t.C1,
Other = b ? new { t.C2, t.C3, t.C4 } : null
};
The SQL executed is:
SELECT
[t].[C1],
[t].[C2],
[t].[C3],
[t].[C4]
FROM
[Tbl1] [t]
The property Other
in the results is null. But it loads the columns C2, C3 and C4 from the DB.
Desired behavior: don’t load columns which aren’t needed.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Asking for unnecessary columns causes ...
It is not about the star, stupid: selecting unnecessary columns is bad.
Read more >sql - Exclude a column using SELECT * [except columnA] ...
If you look at Red-Gate's SQL Prompt, you can type "SELECT * FROM MyTable", and then move the cursor back after the "*",...
Read more >Why can't unused columns and tables be ignored in a ...
Yes, we can obviously see that in the end, the final SELECT list only consists of the CatalogNodeId column, and therefore the other...
Read more >Excel. How to hide all unused cells in all columns ... - YouTube
This video will demonstrate the procedure to hide all unused cells in all columns and rows. Now updated to cover all Excel versions...
Read more >Performance Improvement - Where to reduce number o...
You can delete unnecessary columns in Edit Queries: Ctrl + left mouse button to select multiple columns, then, Right-click and select ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This optimisation is not supported. Currently we do not optimise expression tree based on parameters. Will take a look, probably it makes sense to do that for conditional expression.
I see, forgot to check this cache variant. Here we cache plan by reference. Thanks for mentioned that.