Re: Hash support for grouping sets

Andrew Gierth <andrew@tao11.riddles.org.uk>

From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Mark Dilger <hornschnorter@gmail.com>
Cc: pgsql-hackers@postgresql.org
Date: 2017-03-15T21:51:55Z
Lists: pgsql-hackers

Attachments

Another small update to the patch, this time to eliminate any
possibility of integer overflow when handling extremely large estimated
groupings.

Key change:

-                   k_weights[i] = (int) floor(sz / scale);
+                   /*
+                    * If sz is enormous, but work_mem (and hence scale) is
+                    * small, avoid integer overflow here.
+                    */
+                   k_weights[i] = (int) Min(floor(sz / scale),
+                                            k_capacity + 1.0);

-- 
Andrew (irc:RhodiumToad)

Commits

  1. Support hashed aggregation with grouping sets.