perf(mongodb): do not block the document list on countDocuments (#876) - #969
Merged
ZhuchkaTriplesix merged 1 commit intoSep 25, 2026
Merged
Conversation
#876) MongoDocumentsView._load awaited a full count command before the bounded find, so first paint waited on both round trips and on a collection or filter scan. Paint the first page from find alone and run the count in the background. A short page (or an empty first page) pins the total without any count; while it is pending the footer shows 'N+ documents' and Next is enabled when the page is full. Page navigation reuses the known total, and a sequence number drops responses from superseded loads. A failed count leaves the maybe-more pagination instead of failing the list.
ZhuchkaTriplesix
deleted the
issue/876-mongo-document-list-count-nonblocking
branch
September 28, 2026 08:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание изменений
MongoDocumentsView._loadбольше не ждётcountпередfind: первая страница рисуется сразу послеfind, точный счёт считается в фоне (_loadCount).count:skip + длина страницы. Запрос счёта в этом случае не отправляется.N+ documentsи1 / ?, а Next доступен, когда страница полная (подход «page full ⇒ maybe more», как в SQLite browse).countнет. Фильтр, Refresh, вставка и удаление пересчитывают._loadSeqотбрасывает ответы устаревших загрузок (быстрая смена фильтра или страницы). Ошибкаcountне роняет список, остаётся «maybe more».mongoExactTotalFromPageиmongoHasNextPage, покрытыmongo_documents_paging_test(6 тестов). Этот файл иmongo_field_list_perf_testпрогнал локально, все 8 проходят.Не входит
findбезlimit, как в issue.countна$collStats/ estimated count: точный счёт остаётся, но после первой отрисовки.MongoServiceсинглтон без подмены, поэтому логика вынесена в чистые функции.Связанные Issue
Closes #876