In mongodb_service.dart, pagination (skip and limit) is executed on the client side over a full stream of documents returned by the database:
final stream = coll.find(selector);
...
await for (final doc in stream) {
if (skip != null && count < skip) {
count++;
continue; // Discard client-side
}
...
}
This causes heavy network bandwidth and CPU usage if the user navigates deep into a large collection.
Steps to fix:
Inject skip and limit operations directly into the query selector builder or options map on the database side before fetching the stream:
final selectorBuilder = where;
if (skip != null) selectorBuilder.skip(skip);
if (limit != null) selectorBuilder.limit(limit);
final stream = coll.find(selectorBuilder);
In mongodb_service.dart, pagination (
skipandlimit) is executed on the client side over a full stream of documents returned by the database:This causes heavy network bandwidth and CPU usage if the user navigates deep into a large collection.
Steps to fix:
Inject
skipandlimitoperations directly into the query selector builder or options map on the database side before fetching the stream: