On Tue, 21 May 2024 at 04:00, hubert depesz lubaczewski
<depesz@depesz.com> wrote:
> $ explain (analyze) select count(*) from ( select * from pg_class where relkind = 'r' union select * from pg_class
whererelkind = 'i' );
> QUERY PLAN
>
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
> Aggregate (cost=42.43..42.44 rows=1 width=8) (actual time=0.108..0.109 rows=1 loops=1)
> -> Unique (cost=0.00..39.53 rows=232 width=236) (actual time=0.013..0.105 rows=1 loops=1)
> -> Append (cost=0.00..39.53 rows=232 width=236) (actual time=0.012..0.099 rows=232 loops=1)
> -> Seq Scan on pg_class (cost=0.00..19.19 rows=68 width=263) (actual time=0.012..0.058 rows=68
loops=1)
> Filter: (relkind = 'r'::"char")
> Rows Removed by Filter: 348
> -> Seq Scan on pg_class pg_class_1 (cost=0.00..19.19 rows=164 width=263) (actual time=0.002..0.030
rows=164loops=1)
> Filter: (relkind = 'i'::"char")
> Rows Removed by Filter: 252
Thanks for the report.
It looks like it's a very simple fix. The problem is I wasn't setting
groupList when the grouping_is_sortable() returned false. In the
prior version, make_union_unique() always set that.
The attached should apply cleanly up to d2a04470a.
David