--get_variable_numdistinct
--get_sortgrouplist_exprs
--estimate_num_groups

select
	i as id,
	i/2 as p,
	format('%60s', i%2) as v
	into btg
from
	generate_series(1, 1000000) i;

vacuum btg;
analyze btg;

set enable_hashagg=off;
set max_parallel_workers= 0;
set max_parallel_workers_per_gather = 0;
explain analyze
select
	count(*)
from
	btg
group by
	p, v;

explain analyze
select
	count(*)
from
	btg
group by
	v, p;

create index on btg(p, v);
set enable_seqscan=off;
set enable_bitmapscan=off;
vacuum btg;


explain analyze
select
	count(*)
from
	btg
group by
	v, p
;

explain analyze
select
	count(*)
from
	btg
group by
	v, p
order by p, v
;

