\! pgbench -F 100 -i -s 20 regression

\set VERBOSITY verbose

update pgbench_accounts set filler = 'foo' where aid%10 = 0;

vacuum analyze pgbench_accounts;

set max_parallel_workers_per_gather = 4;

set max_parallel_workers = 4;

explain analyse select count(b.aid) from pgbench_accounts CROSS JOIN pgbench_accounts as a CROSS JOIN pgbench_accounts as b where a.filler like '%foo%'group by a.aid,b.abalance;

explain analyze select sum(aid) from pgbench_accounts where aid % 25= 0 group by aid; --this created a crash which was fixed by dev later

explain analyze select '' AS "xxx" from pgbench_accounts  where filler like '%foo%' group by aid; --performance improved about 65%

explain analyze select distinct(aid) from pgbench_accounts where filler like '%foo%' group by aid; --performance improved about 70%

explain analyze select distinct(bid) from pgbench_accounts where filler like '%foo%' group by aid; --performance improved about 60%

explain analyze select avg(a.aid) from  pgbench_accounts a join pgbench_accounts b using (aid) where a.filler like '%foo%' group by aid; --performance improved about 60%

explain analyse select distinct(aid) from pgbench_accounts where filler in ( select filler from pgbench_accounts where filler like '%foo%') and aid % 25 =0 group by aid;

explain analyze select count(aid) from pgbench_accounts where bid = aid group by bid;

explain analyze select max(abalance) from pgbench_accounts where bid % aid >= aid % bid and aid % 10 = 0 group by bid;

explain analyze select max(bid) from pgbench_accounts where filler like '%foo%' and bid % 10 = 0 group by aid having bid % 10 = 0;

explain analyze select max(bid),min(aid) from pgbench_accounts where aid % 10 = 0 group by bid;

explain analyze select max(bid) from pgbench_accounts where bid <= aid and aid % 10 = 0 group by (aid,bid);

explain analyse select sum(a.bid),min(b.aid) from pgbench_accounts a,pgbench_accounts b where a.aid % 10 = b.aid % 25 group by a.aid;

explain analyze select distinct(a.aid) from  pgbench_accounts a join pgbench_accounts b using (aid) where a.filler like '%foo%' and b.aid % 25 = 0 group by aid;

--This case is under discussion with Developer,why sort node cost is '0'
explain analyze select '' AS "xxx" from pgbench_accounts  where filler like '%foo%' order by aid;
