Hi, I was looking at find_hash_columns() in nodeAgg.c It seems the first loop tries to determine the max column number needed, along with whether all columns are needed.
The loop can be re-written as shown in the patch. In normal cases, we don't need to perform scanDesc->natts iterations. In best case scenario, the loop would terminate after two iterations. Please provide your comment. Thanks
find-hash-col-short-circuit.patch
Description: Binary data