I am trying to understand the memory usage patterns for hash aggregate. The
below query completes in 9.163 seconds and uses 24 MB of memory for
hash-aggregate (according to profile)

select max(d.l_linenumber) from (select l_linenumber, 'asdf' c1, 'kfjhl'
c2, 'reyui' c3, 'khdfs' c4, 'vkhj' c5  from mem_heavy1) d group by d.c1,
d.c2, d.c3, d.c4, d.c5;

Adding one more constant column to the group by, the below query takes
11.638 seconds and uses 29 MB of ram

select max(d.l_linenumber) from (select l_linenumber, 'asdf' c1, 'kfjhl'
c2, 'reyui' c3, 'khdfs' c4, 'vkhj' c5, 'bmkr' c6  from mem_heavy1) d group
by d.c1, d.c2, d.c3, d.c4, d.c5, d.c6;

The below query with one more constant column added to group by 14.622
seconds and uses 33 MB memory

select max(d.l_linenumber) from (select l_linenumber, 'asdf' c1, 'kfjhl'
c2, 'reyui' c3, 'khdfs' c4, 'vkhj' c5, 'bmkr' c6, 'ciuh' c7  from
mem_heavy1) d group by d.c1, d.c2, d.c3, d.c4, d.c5, d.c6, d.c7;


As you can see, there is only one disctinct group in all the above cases.
It looks like the memory usage is proportional to no of elements in the
group by clause. Is this expected?

Is the increase in time expected between the above queries? (As we did not
introduce any new groups)

- Rahul

Reply via email to