Bug: toolbar search fires a request every 600ms while typing and never cancels the previous one
Please confirm that the bug report does not already exist
- I confirm there is no existing issue for this bug.
Steps to reproduce
On a wide table (~100 visible fields, of which 43 are Attachment, 20 Links and 6 Lookup/Rollup/Formula; 1,243 rows), type a name into the toolbar search box at normal typing speed.
Each search fires three requests — GET .../views/{viewId}/count, a second count with the filter, and GET .../views/{viewId}?where=.... On this table the list request takes 0.73 s warm and about 2 s the first time for a given search term.
Measured from the server access log, a real user typing one name:
where=(<field>,like,%abc%) → 10.49 s
where=(<field>,like,%abcd%) → 11.82 sIn one sampled second the server received 40 data requests, 36 of them to /count.
Response-time distribution for one day, same instance, same table:
requests p50 p90 p95 p99 worst
with search 516 0.09s 1.75s 3.22s 9.59s 20.08s
without search 119 0.00s 0.12s 0.63s 0.86s 1.01sSo the median is fine and the tail is not: one search in ten takes over 1.7 s, one in a hundred approaches 10 s.
Expected behavior
Typing a search term should produce one search once the user stops typing, and an in-flight search that is already superseded should not keep occupying the server.
What I think is happening
packages/nc-gui/components/smartsheet/toolbar/SearchData.vue:
watchDebounced(
() => search.value.query,
() => {
onPressEnter()
},
{
debounce: 500,
maxWait: 600,
},
)The debounce is there, but maxWait: 600 caps it: while the user keeps typing, a search is forced every 600 ms regardless. On this table a single search costs 0.73–2 s, so maxWait fires faster than the server can answer and the requests pile up — each one still doing the full row materialisation for a term the user has already moved past.
Two things make it worse together:
maxWaitis shorter than the operation it is debouncing. 600 ms is a reasonable ceiling when a search costs 50 ms; it is counterproductive when it costs 2 s, and the cost scales with how wide the table is, which the front end cannot know.- Nothing cancels the superseded request. When the search for
abcis still running andabcdis issued, both stay in flight. The user only ever sees the last result, so the earlier ones are pure waste — on the client, on the server and on the database.
Suggestions, from least to most work
Let the user opt into explicit search — search on Enter or on a button, not while typing. This is the smallest change of the four and the only one that needs no new code:
onPressEnter()already exists and is already wired to Enter. A per-view or per-instance preference that skips thewatchDebouncedregistration is the whole fix — an absent call, not new behaviour.The reasoning behind it is worth stating plainly, because it generalises past this issue: search-as-you-type is only worth it when searching is cheap. It trades server work for the illusion of instant feedback, and that trade needs the search to come back before the user types the next character. At 50 ms it does. At 0.73–2 s it does not — the user waits either way, and meanwhile the same query has been run four or five times for prefixes nobody wanted. On a wide table a search button is not a downgrade; it is admitting that incremental search has a latency budget this table cannot meet.
Abort the previous search when a new one is issued (
AbortController, or a monotonic request id whose stale responses are dropped). This bounds concurrency at one search per user regardless of howmaxWaitis tuned, and unlike (3) it needs no magic number. Worth doing even if (1) lands, since it also covers the paste-and-edit case.Reconsider
maxWait. Either drop it, so a real pause in typing is what triggers the search, or make it adaptive — never lower than the observed duration of the previous search. A fixed 600 ms is a guess about server cost that does not hold for wide tables, and the front end has no way to know how wide the table is.Skip the two
countrequests while the term is still changing. They were 36 of the 40 requests in the sampled second. The row count only has to be right for the search the user actually settles on.
Happy to test a build against the instance where this reproduces — the effect size is easy to see there, since the same search is 0.003 s when it hits the proxy cache and 2 s when it does not.
Project Details
NocoDB version: 2026.09.0
Self-hosted, Docker, PostgreSQL metadata + data
Node 22, 4 vCPUSource: nocodb/nocodb