Repository navigation
Load tables with wide values and slow links much faster - #432
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ranoctet_length(col::text)andleft(col::text, 512). Each is a full detoast, decompress and jsonb-to-text conversion. Onresume_parsing(454 KB stored, ~1 MB of JSON text per row), over 343 rows:pg_column_size(resume)jsonb_typeof(resume)(detoast only)octet_length(resume::text)left(resume::text, 512)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)
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.Measured (through the slow proxy, debug build)
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_columnstests pass.Not in this PR
The full-page placeholder rows that used to show on a first open are gone (
skeletonRowsin DataTable is computed but unused); a first open still shows the spinner.