Skip to content

Upsert gets slow on tables with many columns #3860

Description

@GaspardMerten

Feature Request / Improvement

upsert compares the matched rows one cell at a time, so it gets slower with every extra column, not just with every extra row.

On a table with 200 columns, comparing 20k matched rows takes around 20 seconds on my machine, before anything is written.

To reproduce:

import time
import pyarrow as pa
from pyiceberg.table.upsert_util import get_rows_to_update

rows, cols = 20_000, 200
table = pa.table({"pk": pa.array(range(rows)), **{f"c{i}": pa.array([float(i)] * rows) for i in range(cols)}})

start = time.monotonic()
get_rows_to_update(table, table, ["pk"])  # nothing has changed
print(time.monotonic() - start)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions