-
-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version 8.4.5 loads the entire table into memory #230
Comments
Should be fixed in https://www.nuget.org/packages/X.PagedList/8.4.6 |
I still have the issue as described above. I'm paging through customer records, but they are all being loaded into memory so it's extremely slow. Happens with 8.4.5 and 8.4.6 also. Reverting to 8.4.3 fixes the issue. |
@tyfarquhar did you pass IQueryable collection? |
Yes, I'll try to get some details, but essentially I'm doing the same as above. I have a huge list of customers that I build an IQueryable query to filter. I then call query.ToPagedListAsync(pagenumber, pagesize); With v8.4.6 it still takes 30+ seconds to complete and I can see it's loading every record into memory. With 8.4.3 and before it's less than a second to complete. |
Looking at Application Insights I can see the difference in the queries generated. Looks like it's not doing a SELECT COUNT in v8.4.6 for me. It's loading every entity and doing the count in memory. In v8.4.3 I have this query: SELECT COUNT(*) In v8.4.6 it just queries all the records instead of a count. |
Debugging it's this line here
|
@tyfarquhar please try install https://www.nuget.org/packages/X.PagedList.EF and use extension method from X.PagedList.EF namespace like it implemented here: https://github.com/dncuug/X.PagedList/blob/fix-ef-paging/examples/Example.Website/Controllers/EFController.cs |
Thank you sir. I'll give it a try. |
Everything is working as expected now. Thanks. |
I am experiencing this same problem with version 9.1.2. If I pass the IEnumerable directly from EF Core to ToPagedList it only retrieves 3 records, however, if I do ToList first the problem is solved. |
@Zaitungtung please provide code example |
Here if I debug "students" it has all the properties I have included (lists, objects, etc.).
At this point I only have the basic type properties (string, int, datetime, etc.) but the lists and custom objects are missing. |
Describe the bug
After upgrade to the new version, when using
await query.ToPagedListAsync(pageNumber, pageSize)
all table data loads into memory! When used together with Entity Framework, 2 queries are actually executed. One loads the entire table into memory, the second loads data only for the selected page.To Reproduce
Steps to reproduce the behavior:
IQueryable<Payment> query = db.Payments.AsNoTracking();
await query.ToPagedListAsync(1, 10);
.ToPagedListAsync
and start profiling real SQL queries.Expected behavior
1 query for counting all rows and 1 query with data only for selected page.
The text was updated successfully, but these errors were encountered: