You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Improvement] Avoid per-key allocations in sort merge #1161
I searched in the issues and found nothing similar.
Motivation
sort_merge_stream allocates for every primary key it merges: current_row().owned() for the winner key and a new Vec<MergeRow> for the rows sharing it. Both can be reused across keys. Encoded rows compare by their bytes, so the key check can compare against a reused byte buffer.
On a primary-key table with 2M keys written three times (6M input rows, 4 files per round, memory FileIO, c7i.4xlarge, release build), a full read goes from 463 ms to 427 ms, about 8%, with and without deletion-vectors.merge-on-read. Six alternating runs each, ranges don't overlap.
Solution
Keep the key buffer and the row list outside the loop and clear them per key.
Activity