Skip to content

fix: Avoid reading delete manifests for Iceberg statistics - #28420

Draft
Nandakumar-Balagopal wants to merge 1 commit into
prestodb:masterfrom
Nandakumar-Balagopal:avoid-delete-manifests-iceberg-stats
Draft

fix: Avoid reading delete manifests for Iceberg statistics#28420
Nandakumar-Balagopal wants to merge 1 commit into
prestodb:masterfrom
Nandakumar-Balagopal:avoid-delete-manifests-iceberg-stats

Conversation

@Nandakumar-Balagopal

@Nandakumar-Balagopal Nandakumar-Balagopal commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Description

Avoid planning and reading Iceberg delete manifests while computing table statistics. The statistics path now reads only applicable data manifests and the required data-file statistics fields.

Motivation and Context

Iceberg table statistics computation currently uses the table scan planning path, which may construct and read delete-file metadata even though delete files are not needed for the data-file statistics calculation. This change reduces unnecessary manifest processing during statistics aggregation.

Impact

No public API or user-facing behavior changes are introduced. Iceberg statistics computation should perform less metadata I/O and use less memory for tables with delete manifests.

Test Plan

  • Full Iceberg test execution.

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
  • If adding new dependencies, verified they have an OpenSSF Scorecard score of 5.0 or higher (or obtained explicit TSC approval for lower scores).

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

Iceberg Connector Changes
* Improve Iceberg table statistics computation by avoiding unnecessary reads of delete manifests.

Summary by Sourcery

Reduce unnecessary metadata processing and resource usage during Iceberg table statistics computation.

Bug Fixes:

  • Avoid reading Iceberg delete manifests when computing table statistics.

Enhancements:

  • Optimize Iceberg statistics computation by planning only applicable data manifests and reading only the data-file fields required for statistics aggregation.

@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Sep 2, 2026
@sourcery-ai

sourcery-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Iceberg statistics computation now directly filters and reads only applicable data manifests and required data-file statistics, avoiding delete-manifest planning and reducing metadata I/O and memory usage without changing public behavior.

Sequence diagram for optimized Iceberg statistics computation

sequenceDiagram
    participant Statistics as TableStatisticsMaker
    participant Table as IcebergTable
    participant Snapshot as Snapshot
    participant Manifest as ManifestFiles
    participant Utils as IcebergLibUtils
    participant Aggregator as StatisticsAggregator

    Statistics->>Table: snapshot(snapshotId)
    Table-->>Statistics: Snapshot
    Statistics->>Snapshot: dataManifests(io)
    Snapshot-->>Statistics: ManifestFile list
    Statistics->>Statistics: ManifestEvaluator.forRowFilter(filter, spec, true).eval(manifest)
    Statistics->>Manifest: read(manifest, io, specs)
    Manifest-->>Statistics: ManifestReader
    Statistics->>Manifest: select(required statistics fields)
    Statistics->>Manifest: filterRows(filter)
    Statistics->>Utils: liveEntries(ManifestReader)
    Utils-->>Statistics: live DataFile entries
    Statistics->>Statistics: copyWithStats(columnIds)
    Statistics->>Aggregator: getSummaryFromFiles(data files)
    Aggregator-->>Statistics: TableStatistics
Loading

File-Level Changes

Change Details Files
Replaces full Iceberg table-scan planning with direct, data-manifest-only statistics collection.
  • Resolves the requested snapshot and filters applicable data manifests using partition-aware manifest evaluators.
  • Reads live manifest entries with only file identity, partition, record-count, and column-statistics fields needed for aggregation.
  • Copies statistics for the selected column IDs before reusing the existing summary computation path.
presto-iceberg/src/main/java/com/facebook/presto/iceberg/TableStatisticsMaker.java
Adds a shared utility for converting live manifest entries into content files.
  • Exposes a closeable iterable of live manifest files without delete-file scan-task construction.
  • Preserves manifest reader resource handling through the existing CloseableIterable abstraction.
presto-iceberg/src/main/java/org/apache/iceberg/IcebergLibUtils.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Nandakumar-Balagopal Nandakumar-Balagopal changed the title fix: avoid reading delete manifests for Iceberg statistics fix: Avoid reading delete manifests for Iceberg statistics Sep 2, 2026
@Nandakumar-Balagopal

Copy link
Copy Markdown
Contributor Author

Initial local benchmark

Tested SHOW STATS FOR iceberg.benchmark.stats_benchmark on a local Hadoop Iceberg catalog using:

  • 60,000 inserted rows
  • 60 small insert commits
  • 10 delete commits producing delete manifests
  • 10 repeated measurements per build
  • First two runs excluded as warm-up

Results using CLI wall-clock time:

Version Median
master ~0.68 s
Feature branch ~0.58 s

The feature branch showed approximately a 15% improvement in this local test. The table returned identical statistics in both versions. This is an initial local result; additional testing with internal statistics timing and remote object storage is still needed.

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

Labels

from:IBM PR from IBM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants