wrolpi/modules/docs
lrnselfreliance 7471b41ae1
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run
docs: browse walks the file_group date index instead of probing every doc (#707)
* docs: browse walks the file_group date index instead of probing every doc

The unfiltered /api/docs/search drove its join from `doc`, so SQLite probed
every doc's file_group row for the sort key before returning the first page.
With 20k docs scattered through a 10 GB database on a spinning disk, the first
request took about a minute cold (0.07s warm).

Use the same CROSS JOIN shape as the archive browse: file_group is the outer
table, SQLite walks file_group_published_datetime_idx and probes doc's covering
unique index on file_group_id. Both sides stay index-only and the scan stops at
the page limit. Measured cold: ~60s -> 0.6s, identical rows.

Filtered searches and the size/title orderings keep the ORM query.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* docs: trim browse comments, stabler plan assertion

Review feedback: drop the benchmark narrative from docstrings, state only the
non-obvious constraint at the call site, and assert the doc covering-index probe
by shape rather than by autoindex name.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 12:39:05 -06:00
..
test docs: browse walks the file_group date index instead of probing every doc (#707) 2026-09-13 12:39:05 -06:00
__init__.py Make doc_modeler resilient to SQLite "database is locked" 2026-07-20 13:44:27 -06:00
api.py Fix API stalls: non-blocking switch worker, threaded searches, indexed Videos page (#678) 2026-08-29 16:17:53 -06:00
conftest.py Add Docs module for searching and organizing PDFs and EPUBs 2026-03-20 14:17:06 -06:00
extractors.py Adding simple search to epub viewer. 2026-04-13 17:23:20 -06:00
lib.py docs: browse walks the file_group date index instead of probing every doc (#707) 2026-09-13 12:39:05 -06:00
models.py Postgres -> SQLite hard cutover: the database moves into the media directory. 2026-07-12 14:09:37 -06:00
schema.py Search: fast ABC mode by default, opt-in deep search 2026-07-03 10:32:16 -06:00