Couple of days ago RhodiumToad reported, on irc, a bug in explain.depesz.com.
Specifically – if explain was done using JSON/XML/YAML formats, and node type was Aggregate, the site didn't extract full info.
In text explains the node type is one of:
- Aggregate
- HashAggregate
- GroupAggregate
But in non-text formats, type of Aggregate was ignored.
As of now, and version 0.92 of Pg::Explain library, Aggregate types are correctly extracted.
You can see it in four tests in here:
Test # | TEXT | JSON | XML | YAML | Query example |
---|---|---|---|---|---|
1 | plan | plan | plan | plan |
select count(*) from pg_class; |
2 | plan | plan | plan | plan |
select relkind, count(*) from pg_class group by 1; |
3 | plan | plan | plan | plan |
with x as (select relkind from pg_class order by relkind) select relkind, count(*) from x group by relkind; |
4 | plan | plan | plan | plan |
select relnamespace, relkind, count(*) from pg_class group by 1, 2; |
Hope it helps.
The fix is unfortunately incomplete, it’s not handling MixedAggregate. A sample query:
select a,count(*) from (values (1)) v(a) group by rollup(a);
@Andrew:
Fixed for json/yaml: https://explain.depesz.com/s/99qr
XML is a bit harder, and with more examples, with more group/hash keys i can’t realistically do it.