Skip to content

perf: weight pruned scan stats by row count - #836

Open
ddupg wants to merge 2 commits into
lance-format:mainfrom
ddupg:perf/ddu-372-zonemap-row-stats
Open

ddupg wants to merge 2 commits into
lance-format:mainfrom
ddupg:perf/ddu-372-zonemap-row-stats

Conversation

@ddupg

@ddupg ddupg commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • estimate post-zonemap scan row counts from deletion-aware row counts of surviving fragments
  • scale byte estimates by the surviving-row ratio before applying projection estimates
  • preserve conservative handling for empty datasets, retired fragments, and non-selective pruning

Testing

  • ./mvnw test -pl lance-spark-3.5_2.13 -am -Dtest=LanceStatisticsTest,LanceSplitTest,LanceScanTest,LanceScanBuilderTest -Dsurefire.failIfNoSpecifiedTests=false
  • ./mvnw spotless:check -pl lance-spark-base_2.12
  • ./mvnw test -pl lance-spark-3.5_2.12 -am -Dtest=LanceStatisticsTest -Dsurefire.failIfNoSpecifiedTests=false

@github-actions github-actions Bot added the performance Features that improves performance label Sep 16, 2026
@ddupg
ddupg marked this pull request as ready for review September 16, 2026 13:02

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gate recommendation: approve.

The equal-fragment assumption is replaced with live, deletion-aware fragment row counts from the same pinned scan plan, while conservative fallbacks remain for empty, non-selective, and inconsistent inputs. Unequal-fragment end-to-end planning and the supported Scala/Spark variants behave as intended; I found no correctness or compatibility blocker.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Sep 16, 2026

@geruh geruh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising @ddupg, did a pass!

@@ -67,6 +67,30 @@ public static LanceStatistics estimatePostPruning(
return new LanceStatistics((long) (totalRows * ratio), (long) (totalFilesSize * ratio));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh interesting, we arent using the estimatePostPruning and is dead code by the looks of it. Maybe we should remove this in a follow up or somehting.

return new LanceStatistics((long) (totalRows * ratio), (long) (totalFilesSize * ratio));
}

/**

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this javadoc is pretty verbose we can probably shorten if not drop the java doc wdyt?

Comment on lines +256 to +257
// Zonemap stats can still contain retired fragment IDs. Only row counts from the live
// fragments in this scan plan may contribute to the estimate.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: getOrDefault(fragmentId, 0L) is already droppping retired ids. the comment on top seems redundant maybe we can drop or simplify?

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

Labels

K-approved Latest Gatekeeper recommendation permits acceptance. performance Features that improves performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants