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

Epic: Statistics improvements #8227

Open
7 of 19 tasks
alamb opened this issue Nov 15, 2023 · 5 comments
Open
7 of 19 tasks

Epic: Statistics improvements #8227

alamb opened this issue Nov 15, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@alamb
Copy link
Contributor

alamb commented Nov 15, 2023

Is your feature request related to a problem or challenge?

We would like to use "statistics" in our project for transformations that rely on the statisics being "correct" (e.g. that the there are no values outside the min and max range).

DataFusion has several optimizations like this too that rely on statistics being correct such as skipping file scans with limits such as in https://github.com/apache/arrow-datafusion/blob/e54894c39202815b14d9e7eae58f64d3a269c165/datafusion/core/src/datasource/statistics.rs#L34-L33. There are also suggestions of additional such optimizations like #6672

However the current Statistics code seems to make it hard to manage the 'are the statistics exact and can they be guaranteed for transformations' (@crepererum noted this quite some time ago on #5613). This has recently lead to several bugs such as

We would like to make it clearer what is known and what is an estimate is know (e.g. the min/max of row counts may be known, but the actual value may be an estimate after a filter). This is described in more detail on #8078

As we began exploring this concept we ran into several issues with Statistics and I think it is getting big enough to warrant its own tracking epic

Related items

Pruning Improvements (maybe should be its own epic)

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

This is somewhat related

@alamb alamb added the enhancement New feature or request label Nov 15, 2023
@suremarc
Copy link
Contributor

suremarc commented Nov 5, 2024

Recently I began looking into implementing #10316, and the proposed approach was to add per-partition statistics to ExecutionPlan and use the information to determine when the partitions have non-overlapping sort keys. However, I realized this requires #8078 to be implemented, as determining whether or not ranges overlap requires upper and lower bounds.

According to @alamb's comment on #8078, the (then) current state of the Statistics code means than implementing #8078 is intractable as of now until other issues with the statistics code are resolved (it seems there were some attempts to simplify the statistics code that ended up not getting completed).

I see that work on this epic has stalled since February, is there interest in continuing it? If so, I'm a willing contributor, but it'd help to know what needs to be done first, in particular if the Statistics code is still in need of some simplification.

@findepi
Copy link
Member

findepi commented Nov 5, 2024

If we have per-partition statistics, merging them will be problematic for NDV. Extrapolation techniques are not likely to work.

@suremarc
Copy link
Contributor

suremarc commented Nov 5, 2024

If we have per-partition statistics, merging them will be problematic for NDV. Extrapolation techniques are not likely to work.

Ok, well I suppose we can keep the existing global statistics and add a new per-partition statistics method (that defaults to returning the global statistics for each partition). That would probably be a less invasive change too.

Would be happy to discuss the details more over on #10316

@alamb
Copy link
Contributor Author

alamb commented Nov 6, 2024

According to @alamb's comment on #8078, the (then) current state of the Statistics code means than implementing #8078 is intractable as of now until other issues with the statistics code are resolved (it seems there were some attempts to simplify the statistics code that ended up not getting completed).

Well, that may have also been my attempt / excuse :) -- especially if I didn't have enough time to work on it

I see that work on this epic has stalled since February, is there interest in continuing it? If so, I'm a willing contributor, but it'd help to know what needs to be done first, in particular if the Statistics code is still in need of some simplification.

I personally think we should go about this from the other end: try to implement the analysis for #10316 -- and use that as a vehicle to make any additional Statistics improvements needed. I think it would help to motivate statistics improvements if we had a real usecase.

Thank you @suremarc and @findepi

@alamb
Copy link
Contributor Author

alamb commented Nov 7, 2024

Here is one idea on how to improve Statistics / Precision. Let me know what you think:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants