Skip to content

Load tables with wide values and slow links much faster - #432

Merged
broisnees merged 1 commit into
nightlyfrom
perf/table-load
Nov 24, 2026
Merged

broisnees merged 1 commit into
nightlyfrom
perf/table-load

Conversation

@broisnees

Copy link
Copy Markdown
Collaborator

Two reports: a resume table with large JSON took ~15 s to open, and on a remote database the grid sat on skeletons for seconds ("Loading rows 54-83 of 208,321", 4.77 s). I reproduced both against the real database, with a local proxy adding 40 ms each way and a 10 Mbit download cap.

Wide values (Rust, wide_columns.rs)

The page query decided per value with pg_column_size (free: it reads the varlena header), but values between 1 KB and the 256 KB cap also ran octet_length(col::text) and left(col::text, 512). Each is a full detoast, decompress and jsonb-to-text conversion. On resume_parsing (454 KB stored, ~1 MB of JSON text per row), over 343 rows:

expression time
pg_column_size(resume) 3 ms
jsonb_typeof(resume) (detoast only) 2.8 s
octet_length(resume::text) 14.2 s
left(resume::text, 512) 13.7 s

The projection is now one branch on pg_column_size > 4096: past it a value ships as its stored size (the cell's existing "N KB jsonb" look) and loads whole when opened. The full table went from 11.8 s to 0.6 s of server time, and 343 rows from 1.7-3.1 s to 113 ms. The size shown is the stored (compressed) size.

Windows and first paint (frontend)

  • Window target 2 MB to 600 KB; heavy-view bar 8 MB to 1.5 MB, so a few thousand wide rows stream in windows instead of one response with nothing past row 200 until it lands.
  • fillVisibleGap: rows on screen that the window in flight does not cover yet (a scroll past the screenful fetched first) are fetched alone, in the same load generation so it never cancels that window.
  • Views under 10,000 rows fill their remaining windows in the background, one at a time, once nothing on screen is waiting.
  • First open: the table's primary key comes from the schema's column structure (now loaded once per schema with the table list), so the probe is in window order and is kept as window 0. Without it, the probe only measures, at 20 rows instead of 200. The probe is 100 rows otherwise.
  • A fresh view resets the previous view's visible range, which made window 0 refetch the screenful the probe had just painted.

Measured (through the slow proxy, debug build)

  • 208k-row audit_notification_logs, first open: first 100 rows in 0.44 s, then 709-row windows of 0.6 MB at ~0.8 s each.
  • resume_parsing: 100-row windows of ~0.7 MB under a second each; the whole table streams in.

npm test, svelte-check, design lint and the Rust wide_columns tests pass.

Not in this PR

The full-page placeholder rows that used to show on a first open are gone (skeletonRows in DataTable is computed but unused); a first open still shows the spinner.

Wide columns are decided on pg_column_size alone (header only) and ship
as their stored size past 4KB. The old middle branch ran
octet_length(col::text) and left(col::text, 512), each a full detoast
and jsonb-to-text conversion: on a 454KB-a-row resume table, 343 rows
spent 14s in one and 14s in the other against 3ms for pg_column_size,
and a full load of 1,762 rows went from 11.8s of server time to 0.6s.

Window target 2MB to 600KB, heavy-view bar 8MB to 1.5MB, first probe
200 to 100 rows. Rows on screen that their in-flight window does not
cover yet are fetched alone (fillVisibleGap), and views under 10,000
rows fill their remaining windows in the background. A first open
reads the table's primary key from the schema's column structure, so
the probe is in window order and becomes window 0 instead of being
fetched twice; without it the probe only measures, at 20 rows. A fresh
view resets the stale visible range that made window 0 refetch the
screenful the probe had just painted.

Measured against a remote Postgres through a 40ms-each-way, 10 Mbit
proxy: first rows of a 208k-row table in 0.44s, and the resume table
streams 100-row windows in under a second each.
@broisnees broisnees added the release:patch Default for PRs into nightly: next patch (.9 rolls to the next minor). On master: hotfix release label Nov 24, 2026
@broisnees
broisnees merged commit 0b0ec62 into nightly Nov 24, 2026
1 check passed
@broisnees
broisnees deleted the perf/table-load branch November 24, 2026 17:13
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release:patch Default for PRs into nightly: next patch (.9 rolls to the next minor). On master: hotfix release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant