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

core: Make NDV non-zero #1985

Merged
merged 1 commit into from
Nov 14, 2024
Merged

core: Make NDV non-zero #1985

merged 1 commit into from
Nov 14, 2024

Conversation

kim
Copy link
Contributor

@kim kim commented Nov 12, 2024

Change TxId::num_distinct_values to return Option<NonZeroU64>.

It will now return None if either the table doesn't exist, no index
exists for the given column list, or the index is empty.
Otherwise, Some non-zero number of distinct values is returned.

Fixes a division-by-zero bug in the query row estimation.

Expected complexity level and risk

1

Testing

No functional change, estimation::index_row_est is now statically guaranteed
to not panic due to division-by-zero

Change `TxId::num_distinct_values` to return `Option<NonZeroU64>`.

It will now return `None` if either the table doesn't exist, no index
exists for the given column list, or the index is empty.
Otherwise, `Some` non-zero number of distinct values is returned.

Fixes a division-by-zero bug in the query row estimation.
@kim kim force-pushed the kim/fix/nonzero-ndv branch from 047827f to 16a7126 Compare November 14, 2024 10:56
@kim kim added this pull request to the merge queue Nov 14, 2024
Merged via the queue into master with commit 33c4aab Nov 14, 2024
8 checks passed
@kim kim deleted the kim/fix/nonzero-ndv branch November 14, 2024 11:34
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.

4 participants