Skip to content

Conversation

lnkuiper
Copy link
Contributor

Fixes a bug introduced by #17140

The computation was wrong because it did not check has_estimated_cardinality before grabbing it. This PR computes the cardinality if it was not yet there. These fields should probably be changed to optional_idx in the future so this doesn't happen.

@lnkuiper lnkuiper requested a review from Tmonster May 26, 2025 08:59
Copy link
Contributor

@Tmonster Tmonster left a comment

Choose a reason for hiding this comment

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

LGTM, just comments about some comments

@duckdb-draftbot duckdb-draftbot marked this pull request as draft May 26, 2025 15:04
@lnkuiper lnkuiper marked this pull request as ready for review May 27, 2025 14:41
@lnkuiper
Copy link
Contributor Author

Thanks for the feedback!

@xuke-hat
Copy link
Contributor

xuke-hat commented May 27, 2025

Slightly off-topic, but the 0.007 threshold was tested without #17141. Given the discussion in #17140 (latest comment), should we revisit this value?

@lnkuiper
Copy link
Contributor Author

@xuke-hat Agree, but we definitely want to wait with benchmarking until #17584 is merged, which is a full reimplementation of sorting, which is much more sensitive to aborting early with a LIMIT on top

This targets the bugfix release branch, while the sort rework targets the main branch, so we should do this after the bugfix branch has been merged into main, too, might be 1-2 weeks.

@Mytherin Mytherin merged commit ca7af7f into duckdb:v1.3-ossivalis May 28, 2025
50 checks passed
@Mytherin
Copy link
Collaborator

Thanks!

krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Jun 2, 2025
Don't bail on TopN optimization if we don't have a cardinality (duckdb/duckdb#17654)
@lnkuiper lnkuiper deleted the topn_fix branch July 8, 2025 08:25
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