File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,11 @@ static void OptimizePostgresScanLimitPushdown(unique_ptr<LogicalOperator> &op) {
53
53
}
54
54
55
55
auto &bind_data = get.bind_data ->Cast <PostgresBindData>();
56
+ if (bind_data.max_threads != 1 || !bind_data.can_use_main_thread ) {
57
+ // cannot push down limit/offset if we are not using the main thread
58
+ OptimizePostgresScanLimitPushdown (op->children [0 ]);
59
+ return ;
60
+ }
56
61
57
62
string generated_limit_clause = " " ;
58
63
if (limit.limit_val .Type () != LimitNodeType::UNSET) {
Original file line number Diff line number Diff line change @@ -39,3 +39,35 @@ query II
39
39
EXPLAIN FROM s.large_tbl LIMIT 5;
40
40
----
41
41
logical_opt <!REGEX>:.*LIMIT.*
42
+
43
+
44
+ statement ok
45
+ set pg_pages_per_task=1
46
+
47
+ query I
48
+ FROM s.large_tbl LIMIT 5
49
+ ----
50
+ 0
51
+ 1
52
+ 2
53
+ 3
54
+ 4
55
+
56
+ query I
57
+ FROM s.large_tbl LIMIT 5 OFFSET 5
58
+ ----
59
+ 5
60
+ 6
61
+ 7
62
+ 8
63
+ 9
64
+
65
+ statement ok
66
+ set explain_output='optimized_only'
67
+
68
+ # limit is still in plan as we were not able to push down due to parallel execution
69
+
70
+ query II
71
+ EXPLAIN FROM s.large_tbl LIMIT 5;
72
+ ----
73
+ logical_opt <REGEX>:.*LIMIT.*
You can’t perform that action at this time.
0 commit comments