Re: queries with DISTINCT / GROUP BY giving different plans
| От | Tomas Vondra |
|---|---|
| Тема | Re: queries with DISTINCT / GROUP BY giving different plans |
| Дата | |
| Msg-id | 52138785.8010607@fuzzy.cz обсуждение исходный текст |
| Ответ на | Re: queries with DISTINCT / GROUP BY giving different plans (Tomas Vondra <tv@fuzzy.cz>) |
| Список | pgsql-performance |
On 16.8.2013 21:36, Tomas Vondra wrote:
>
> Now, the difference between 24 and 56 is caused by hash_agg_entry_size.
> It's called with numAggs=0 but returns 32. I'm wondering if it should
> return 0 in such cases, i.e. something like this:
>
> Size
> hash_agg_entry_size(int numAggs)
> {
> Size entrysize;
>
> if (numAggs == 0)
> return 0;
>
> /* This must match build_hash_table */
> entrysize = sizeof(AggHashEntryData) +
> (numAggs - 1) * sizeof(AggStatePerGroupData);
> entrysize = MAXALIGN(entrysize);
> /* Account for hashtable overhead (assuming fill factor = 1) */
> entrysize += 3 * sizeof(void *);
> return entrysize;
> }
>
> I've tested that after this both queries use HashAggregate (which is the
> right choice), but I haven't done any extensive checking so maybe I'm
> missing something.
So, is this a sufficient / correct explanation? Any comments about the
fix I suggested? Or should I try to get a permission to provide the data
so that you can reproduce the issue on your own? That might take a few
days to get through.
Tomas
В списке pgsql-performance по дате отправления: