gpdb
gpdb copied to clipboard
(6x only) CUBE is limited to at most have 12 elements.
Arbitrarily cap the size of CUBE, which has exponential grow is not a computationable SQL. Disallow elements more than 12 to keep align with upstream.
- Master branch already have this kind of code when merging PG9.6. So this PR is only for 6X.
- I add a field in the parse tree's struct, append the filed at the end of the struct, so it should not break ABI
- In my local VM (very small machine), it runs 36 sec to generate a plan for the following SQL with 12 elements (NOTE the main part of explain cannot be interrupted still).
gpadmin@zlyu:~/workspace/gpdb$ psql
psql (9.4.26)
Type "help" for help.
gpadmin=# \timing
Timing is on.
gpadmin=# set statement_mem = '2GB';
SET
Time: 28.256 ms
gpadmin=# explain select c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c25, c26, c27, sum(c26) from t group by cube(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11), c25, c26, c27;
Gather Motion 3:1 (slice925; segments: 3) (cost=4394.86..3463873.05 rows=8149366 width=80)
-> Append (cost=4394.86..3463873.05 rows=2716456 width=80)
-> HashAggregate (cost=4394.86..4611.33 rows=7216 width=80)
Group Key: "rollup".c25, "rollup".c26, "rollup".c27, "rollup".c11, "rollup".c10, "rollup".c9, "rollup".c8, "rollup".c7, "rollup".c6, "rollup".c5, "rollup".c4, "rollup".c3, "rollup".c2, "rollup".c1, "rollup".c0, "rollup"."grouping", "rollup"."group_id"
-> Subquery Scan on "rollup" (cost=2146.67..4364.44 rows=226 width=80)
............
Time: 38780.634 ms