I am using pagination for mat-table and for that I have written mongoldb query as follows, but this query is not working for big data it is giving error as : Executor error during find command :: caused by :: Sort operation used more than the maximum 33554432 bytes of RAM. Add an index, or specify a smaller limit.
const sort = { orderId: -1 };
collection.find({ status: { $ne: "cancel" } }).sort(sort).limit(pageSize).skip(skips).toArray(function (err, response) {});
I am expecting output in defending order according to orderid
.