Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added greater and less than query optimization to snapshot table queries #3396

Conversation

ctrlaltdilj
Copy link
Contributor

optimizing queries on snapshot table

if (snapshotPred != null && snapshotPred.function() instanceof Equal) {
specificSnapshot = (Long) snapshotPred.literals().get(0);
if (snapshotPred != null) {
if (snapshotPred.function() instanceof Equal) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This will cause performance degradation of equal, because this requires list files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Originally I had preserved the efficiency in snapshotsWithinRange, with the new code removing the list call it should still be efficient with the iterating on a single snapshopId

Copy link
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

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

Thanks @ctrlaltdilj for the contribution!

Left one comment.

return Collections.singletonList(snapshot(maxSnapshotId)).iterator();
}

return listVersionedFiles(fileIO, snapshotDirectory(), SNAPSHOT_PREFIX)
Copy link
Contributor

Choose a reason for hiding this comment

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

We still need to list directory.
Can we directly read one by one?

We can combine maxSnapshotId, minSnapshotId, earliest and latest. Calculate a queryable interval and directly call the snapshot method one by one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed list call, lmk what you think

@ctrlaltdilj ctrlaltdilj requested review from JingsongLi and Zouxxyy June 3, 2024 05:04
Copy link
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

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

+1

@JingsongLi JingsongLi merged commit fed70b0 into apache:master Jun 4, 2024
9 checks passed
JingsongLi pushed a commit that referenced this pull request Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants