search: don't COUNT(*) OVER() the page query (#702)

COUNT(*) OVER() forced SQLite to visit every matching file_group
before LIMIT, which is a full table scan of the (large) file_group
table — ~22s cold on a Pi for videos ordered by download date.

Count separately and cache for 60s by filters so indexed orders can
stop after one page.  Past-the-end pages now report the true total.
Videos/archives/docs pagers keep totalPages across page changes.
This commit is contained in:
lrnselfreliance 2026-09-12 14:44:10 -06:00 • committed by Roland
parent 0b61d3ab08
commit 8008cd1fd8
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
9 changed files with 436 additions and 74 deletions

View file

@ -523,7 +523,6 @@ export const useSearchArchives = (defaultLimit) => {
const localSearchArchives = async () => {
setArchives(null);
setTotalPages(0);
try {
let [archives_, total] = await searchArchives(offset, limit, domain, searchStr, order, activeTags, headline,
deep);
@ -594,7 +593,6 @@ export const useSearchDocs = (defaultLimit) => {
const localSearchDocs = async () => {
setDocs(null);
setTotalPages(0);
try {
const mimetype = docFilterToMimetype(filter);
let [docs_, total] = await searchDocs(offset, limit, searchStr, order, activeTags, author, subject,
@ -657,7 +655,6 @@ export const useSearchVideos = (defaultLimit, channelId, order_by) => {
const localSearchVideos = async () => {
setVideos(null);
setLoading(true);
setTotalPages(0);
try {
let [videos_, total] = await searchVideos(offset, limit, channelId, searchStr, order, activeTags, headline,
censored, deep);