A search for a very common word still takes about two seconds #472

Closed
opened 2026-11-16 18:05:06 -08:00 by rays · 1 comment
Owner

After #459, a search answers in 25-95 ms for most words, but one in about one item in nine ('apple': 75,000 matches across the catalogue) takes about 1.9 s through /api/entries: the count (2.1 s cold) and the page of 50 (1.1 s) each re-check the text of every candidate the trigram index gives (EXPLAIN on production, 2026-11-17). Ways out: count a search's matches only up to a cap (1,000, shown as 1,000+), and for the page walk entries newest first through an index and stop at 50 matches, which a common word reaches quickly.

After #459, a search answers in 25-95 ms for most words, but one in about one item in nine ('apple': 75,000 matches across the catalogue) takes about 1.9 s through /api/entries: the count (2.1 s cold) and the page of 50 (1.1 s) each re-check the text of every candidate the trigram index gives (EXPLAIN on production, 2026-11-17). Ways out: count a search's matches only up to a cap (1,000, shown as 1,000+), and for the page walk entries newest first through an index and stop at 50 matches, which a common word reaches quickly.
rays added the bug label 2026-11-16 18:05:06 -08:00
Author
Owner

Fixed in 2ebe77b, deployed: on Postgres a search gives the planner this person's feeds as an array (= ANY(ARRAY(...))) instead of a subquery, so it no longer matches the word in every feed on the server first. Live through the API, warm: 'apple' 0.12 s (was 1.9 s, 0.48 s cold), 'the' 0.08 s, 'kubernetes' 0.03 s. The count stays exact; no cap was needed.

Fixed in 2ebe77b, deployed: on Postgres a search gives the planner this person's feeds as an array (= ANY(ARRAY(...))) instead of a subquery, so it no longer matches the word in every feed on the server first. Live through the API, warm: 'apple' 0.12 s (was 1.9 s, 0.48 s cold), 'the' 0.08 s, 'kubernetes' 0.03 s. The count stays exact; no cap was needed.
rays closed this issue 2026-11-16 18:16:13 -08:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rays/ipx#472