Impala Public Jenkins has submitted this change and it was merged. ( 
https://gerrit.cloudera.org/25223 )

Change subject: IMPALA-15710: Improve Hive ACID delete cardinality estimation
......................................................................

IMPALA-15710: Improve Hive ACID delete cardinality estimation

Before this change, the cardinality estimate of the delete delta scan
was based on the row count stats of the scanned partitions, i.e. it
assumed that all rows were deleted. This could massively
overestimate, leading to inflated memory estimates in the anti-join
operator that applies the deletes.

As there are no stats for the number of deleted rows, an estimate
based on the file sizes of the delete deltas is used to cap the
original estimate, so the change can only lower estimates. Based on
measurements, delete delta files written by Hive contain ~0.1-1.2
bytes per deleted row. 0.2 bytes per row is chosen as the estimate to
avoid severe underestimation. The footer of the files contains the
schema of the table, so the per-file overhead grows with the number
of columns (~750 bytes for 2 columns, ~1300 bytes for 16 columns). A
minimal overhead of 600 bytes is used, as overestimating small files
by a few thousand rows is less harmful than underestimating many
small files.

The new estimate is only too low if the delete events compress better
than 0.2 bytes per row, which was only seen when deleting a contiguous
range of rows (~2x underestimation). If the table has no row count
stats or stats extrapolation is enabled, the original estimate is
based on the file sizes and the row width of the table, and is
usually lower than the new one, so it is kept.

Testing:
- Added an exhaustive-only test in test_acid.py that deletes rows from
  a table with Hive and checks the estimates before and after
  computing stats. The existing planner test tables have no row count
  stats, so the change makes no difference for them and the planner
  test outputs remain the same.
- Manually verified on full ACID tables with row count stats and
  deletes done by Hive:
  - copy of tpch.lineitem with 1 deleted row: estimated 3.46K rows
    instead of 6M, the anti-join's memory estimate drops from 306MB
    to 1.94MB
  - copy of tpch.lineitem with 1.74M deleted rows in 6 files:
    estimated 4.26M rows, unchanged as the cap is not lower than the
    row count stats
  - 2-column table with 102K rows, deleting 1000 rows 10 times (240
    small delete files): estimated 92.2K rows (unchanged) for 10K
    actual deleted rows

Change-Id: Idff7be9d675829179ba3e67f9ad9d94b369f8497
Assisted-by: Claude Opus 5.5 (Claude Code)
Reviewed-on: https://gerrit.cloudera.org/25223
Reviewed-by: Impala Public Jenkins <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>
---
M fe/src/main/java/org/apache/impala/planner/HdfsScanNode.java
M fe/src/main/java/org/apache/impala/planner/SingleNodePlanner.java
M tests/query_test/test_acid.py
M tests/util/parse_util.py
4 files changed, 141 insertions(+), 1 deletion(-)

Approvals:
  Impala Public Jenkins: Looks good to me, approved; Verified

--
To view, visit https://gerrit.cloudera.org/25223
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Idff7be9d675829179ba3e67f9ad9d94b369f8497
Gerrit-Change-Number: 25223
Gerrit-PatchSet: 4
Gerrit-Owner: Csaba Ringhofer <[email protected]>
Gerrit-Reviewer: Aleksandr Efimov <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Zoltan Borok-Nagy <[email protected]>

Reply via email to