Skip to content

perf(mongodb): do not block the document list on countDocuments (#876) - #969

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
issue/876-mongo-document-list-count-nonblocking
Sep 25, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
issue/876-mongo-document-list-count-nonblocking

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Описание изменений

  • 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 проходят.

Не входит

  • Размер страницы 25 и find без limit, как в issue.
  • Замена точного count на $collStats / estimated count: точный счёт остаётся, но после первой отрисовки.
  • Виджет-тест самого списка: MongoService синглтон без подмены, поэтому логика вынесена в чистые функции.

Связанные Issue

Closes #876

#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.
@github-actions github-actions Bot added frontend Theme parser epic label: frontend performance Theme parser epic label: performance backend Backend database driver execution and queries labels Sep 25, 2026
@github-actions github-actions Bot added this to the 0.4.18 milestone Sep 25, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 65b1878 into dev Sep 25, 2026
3 checks passed
@ZhuchkaTriplesix
ZhuchkaTriplesix deleted the issue/876-mongo-document-list-count-nonblocking branch September 28, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Backend database driver execution and queries frontend Theme parser epic label: frontend performance Theme parser epic label: performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant