cloudberry
cloudberry copied to clipboard
Support SELECT FETCH WITH TIES in ORCA
create table t11(a int, b int);
insert into t11 select i%3, i from generate_series(1,15)i;
gpadmin=# set optimizer=off;
SET
gpadmin=# select * from t11 order by a fetch first 2 rows with ties;
a | b
---+----
0 | 15
0 | 3
0 | 6
0 | 9
0 | 12
(5 rows)
gpadmin=# set optimizer=on;
SET
gpadmin=# select * from t11 order by a fetch first 2 rows with ties;
a | b
---+----
0 | 15
0 | 3
(2 rows)
https://www.jooq.org/doc/latest/manual/sql-building/sql-statements/select-statement/with-ties-clause/