Skip to content

Bound term-info sub-query counts; never re-run unbounded to count#59

Merged
Robbie1977 merged 1 commit into
mainfrom
feature/term-info-bounded-count
Jun 28, 2026
Merged

Bound term-info sub-query counts; never re-run unbounded to count#59
Robbie1977 merged 1 commit into
mainfrom
feature/term-info-bounded-count

Conversation

@Robbie1977

Copy link
Copy Markdown
Contributor

Generic high-level terms (e.g. FBbt_00000006 'head segment') hung get_term_info: a saturated preview triggered an unbounded limit=-1 re-run of the sub-query purely to count rows, materialising every row with full markdown/thumbnail encoding. The cold call never returned, so the v3-cached proxy never populated and every hit re-triggered it.

  • fill_query_results: replace the limit=-1 count re-run with a COUNT_CAP-bounded re-run (env VFBQUERY_COUNT_CAP, default 1000); exact total under the cap, otherwise -1 ("many").
  • get_instances: add a count(*) aggregation over the same MATCH/OPTIONAL grain so the true total comes back with the preview LIMIT applied, skipping the re-run entirely.
  • Wrap every sub-query call in a wall-clock budget (env VFBQUERY_SUBQUERY_TIMEOUT_S, default 600); on overrun emit an empty preview and count -1 so term-info as a whole always resolves and caches.
  • Use count -1 (unknown) not 0 for timed-out/failed sub-queries so the panel keeps them live and distinguishable from known-empty results.

Generic high-level terms (e.g. FBbt_00000006 'head segment') hung
get_term_info: a saturated preview triggered an unbounded limit=-1
re-run of the sub-query purely to count rows, materialising every row
with full markdown/thumbnail encoding. The cold call never returned, so
the v3-cached proxy never populated and every hit re-triggered it.

- fill_query_results: replace the limit=-1 count re-run with a
  COUNT_CAP-bounded re-run (env VFBQUERY_COUNT_CAP, default 1000); exact
  total under the cap, otherwise -1 ("many").
- get_instances: add a count(*) aggregation over the same MATCH/OPTIONAL
  grain so the true total comes back with the preview LIMIT applied,
  skipping the re-run entirely.
- Wrap every sub-query call in a wall-clock budget (env
  VFBQUERY_SUBQUERY_TIMEOUT_S, default 600); on overrun emit an empty
  preview and count -1 so term-info as a whole always resolves and caches.
- Use count -1 (unknown) not 0 for timed-out/failed sub-queries so the
  panel keeps them live and distinguishable from known-empty results.
@Robbie1977 Robbie1977 merged commit c2171d1 into main Jun 28, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant