I am using the MongoDB 2.6.7 in Windows 7 (64 bit) with MongoDB C# Driver 1.10.0 and I am facing the following error:
MongoDB.Driver.MongoQueryException: QueryFailure flag was getMore runner error: Overflow sort stage buffered data usage of 33554527 bytes exceeds internal limit of 33554432 bytes (response was { "$err" : "getMore runner error: Overflow sort stage buffered data usage of 33554527 bytes exceeds internal limit of 33554432 bytes", "code" : 17406 }).
The query I run in C# is:
var query = Query<User>.EQ(c => c.GroupId, groupId);
return Collection.Find(query)
.SetSortOrder(SortBy.Ascending(User.ID))
.SetSkip(page * records)
.SetLimit(records)
.ToList();
I am using an single index for GroupId property and also the ID (with _id value) property has the default index.
I see that there is a related bug in the MongoDB:
https://jira.mongodb.org/browse/SERVER-14174
How can I solve this error?
The server issue you've highlighted isn't really related. The error you are encountering indicates too much data (>32Mb) for an in-memory sort. Adding an appropriate index should resolve this. It looks like your User collection should have a compound index on { groupId:1, _id:1}
.
Order in compound keys is definitely important. For some helpful background reading see: Optimizing MongoDB Compound Indexes .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.