Fix for displaying aggregates on explain.depesz.com

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.

2 thoughts on “Fix for displaying aggregates on explain.depesz.com”

  1. 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);

Comments are closed.