ChildrenQueryable 10 x slower than new Query
See original GitHub issueHey,
when i’m doing
var isbnGroups = _isbnService.GetAllISBNGroups().ToList();
var list = new List<ISBNGroupModel>();
foreach (var group in isbnGroups)
{
list.Add(new ISBNGroupModel()
{
BaseNumber = group.BaseNumber,
Count = group.Count,
AvailableCount = group.Numbers.ChildrenQueryable().Count()
});
}
return Ok(list);
it takes about 700-900 ms, with 1 ISBN Group and 9999 ISBNs (Numbers)
when doing
var isbnGroups = _isbnService.GetAllISBNGroups().ToList();
var list = new List<ISBNGroupModel>();
foreach (var group in isbnGroups)
{
var childrenCount = DB.Queryable<ISBN>().Count(x => x.ISBNGroup.ID == group.ID);
list.Add(new ISBNGroupModel()
{
BaseNumber = group.BaseNumber,
Count = group.Count,
AvailableCount = childrenCount
});
}
return Ok(list);
it takes about 48-172 ms…
Btw, is there a better way to count a Many Child Collection?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Entity Framework query slow, but same SQL in SqlQuery is ...
The reason of slowing down my EF queries was comparing not nullable scalars with nullable scalars: long? userId = 10; // nullable scalar...
Read more >sql server - Why would a query in code be slower than a ...
We are currently facing an issue where the same query executed in the code takes (on average) 15-20 seconds. The same query on...
Read more >Same queries run slower on new system?
I have identical copies of MAINDB on OLDBOX and NEWBOX, and NEWBOX beats OLDBOX's performance by a solid 10-20% for running reports. Oddly, ......
Read more >Very Slow SQL query - Fast in SSMS
I have an additional CF10 server that seems to run the query perfectly fine on a test page. The query is pretty much...
Read more >Troubleshoot slow-running queries - SQL Server
This article describes how to handle a performance issue that applications may experience when using SQL Server.
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 FreeTop 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
Top GitHub Comments
released v8.10 with
Many<T>.ChildrenCount()
which does the above internally.will you let me know how fast this method works on your 10k isbn records? thanks!
Oh btw, its around 35 ms, where my fastest hack implementation was 48 ms