Skip to content

fix(standardize): picking each record's current version after every transform OOMs at 10M — the window buffers all ~25 standardized columns #1494

Done

Description

@athvin

Found in #558 on er-dev (2026-11-30). With #1475's staged ingest, standardize at 10M records failed Out of Memory (7.4/7.4 GiB) three minutes in, at class L.

Reproduced locally at 2M rows, with memory scaled to 1.5 GB:

Bisected: length(payload), json_extract_string and json_keys all scan cheaply. The cost is current_version. It applies row_number() over (partition by source_system, source_record_id order by ingested_at desc, ingest_batch_id desc) after every source arm's transforms, so the window buffers every version with all of its ~25 standardized string columns.

Fix: pick the current version on the narrow raw rows first. Every partition and order key is a raw column, and tombstones are filtered afterwards as before. Then transform only those rows. The output is identical. Done when standardize at 2M passes at 1.5 GB on the single-file layout, the std goldens are unchanged, and #558's 10M run gets past standardize.

Activity

  1. added
    followup
    on Nov 30, 2026
  2. athvin commented on Nov 30, 2026

    @athvin
    OwnerAuthor

    Correction from the bisect. The late window was not the cause. Picking the current version on raw rows first still OOMed, so that change is not in the fix.

    What the evidence shows, locally at 2M rows with 1.5 GB:

    • raw_records as one Parquet file: standardize OOMs at 4 and 12 threads, passes at 1–2 threads. Single expressions such as phone_e164 fail in 0.1 s at 12 threads.
    • Small row groups inside one file (2048, 4096, 16384) still OOM. So do 2,000- and 20,000-row files. Disabling parquet prefetching or the metadata cache doesn't help.
    • 500-row files: pass at 12 threads (165–200 s), twice.

    So the variable is the file. The fix: ingest keeps #1475's single staged appender, but writes raw_records in 500-row seq slices, one short INSERT … SELECT each. Ingest at 2M went from 106 s to 112 s (debug build), with 4,000 files, the old layout, and standardize passes at 1.5 GB / 12 threads.

  3. athvin commented on Nov 30, 2026

    @athvin
    OwnerAuthor

    I repeated the comparison on an independent two-million-record synthetic CRM corpus using the production person SQL generator and DuckDB 2.0.1. The input was one 111 MiB Parquet file, the memory limit was 1.5 GB, and the output was an on-disk DuckDB table.

    Input and query DuckDB threads Outcome
    Single file, original standardization 4 OOM after 3.688 s
    Single file, rank raw rows before transforming 4 OOM after 4.792 s
    Single file, original standardization 2 OOM after 7.403 s
    Single file, original standardization 1 2,000,000 rows and distinct record keys in 181.206 s
    Same records, 4,000 files of 500 rows each, original standardization 4 OOM after 8.799 s
    Same 4,000 files, original standardization 1 2,000,000 rows and distinct record keys in 277.148 s

    The successful single-file and 4,000-file outputs matched on every column and row multiplicity. I checked both directions with EXCEPT ALL in 40 ranges of 50,000 keys. Ranking the raw rows in isolation passed on this corpus. Restoring the standardization expressions triggered the memory failure again. I discarded the raw-window patch. The one-thread result provides a recovery option for this already-written file. The small-file comparison here used a direct Parquet scan. The reported DuckLake measurement above remains the evidence for the staged-ingest layout. The er-dev 10M result belongs to #558.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    followup

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions