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.