Skip to content

Execute find and count queries in parallel for paginated requests #43

@winrono

Description

@winrono

When find request is executed with pagination actual find and count requests are executed sequentially.

const results = await this._collection.find(query, options);
if (!hasPaging) {
return {
results,
};
}
const countOptions = {};
if (options.session) countOptions.session = options.session;
const count = await this._collection.count(query, countOptions);

Instead this could be performed in parallel noticeably improving performance for long-running DB requests

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions