Skip to content

Conversation

@noahisaksen
Copy link
Contributor

@noahisaksen noahisaksen commented Jan 4, 2026

To fix LIMIT returning more than the expected rows, this PR guarantees single-task/thread execution when LIMIT Pushdown occurs.

Relevant issues: #380 #395

BACKGROUND:

LIMIT Pushdown introduced big optimization but also an issue where LIMIT N would return more than N results, due to some thread and tasking.

Initially fixed in #330 , where we only apply LIMIT Pushdown, if max_threads == 1. This did not cover all cases.

As suggested by @Mytherin already on the PR above, it may be better to set threads and tasks to 1, when LIMIT optimization can be applied. This PR does that.


Before fixes applied, Test 4 inside test/sql/storage/limit_parallel_bug.test was failing by returning more than 1 row. To recreate #395


This PR removes the check made in #330 in favor of setting the amount of threads and tasks.

LIMIT is now always pushed down to Postgres with single-task execution
enforced, so the EXPLAIN test should expect no LIMIT in the DuckDB plan
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.

1 participant