RE: Re: Spilling hashed SetOps and aggregates to disk

Поиск
Список
Период
Сортировка
От serge@rielau.com
Тема RE: Re: Spilling hashed SetOps and aggregates to disk
Дата
Msg-id 20180605083902.9cf3801d03770ada01bb39dc8f52321d.8e74dafc00.mailapi@email18.godaddy.com
обсуждение исходный текст
Ответ на Re: Spilling hashed SetOps and aggregates to disk  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Ответы Re: Re: Spilling hashed SetOps and aggregates to disk  (Jeff Davis <pgsql@j-davis.com>)
Список pgsql-hackers
Strange. We don't see this overeahd and measure a lot more than just a single metric:
 
Of the grab below only the context->stats += size is need.
Could easily be a macro.
We also track overall backend size to cap it, and track memory contexts in shared memory (plan cache, function cache, message and transaction contexts).
Each with high watermarks.
 

/*
* NOTE: Shared contexts stats are global and shared by
 * all engines, so, never add the size directly, instead
 * use stats API which uses Atomic.*() calls to ensure
 * mutual exclusion.
 */

static void MaintainAllocStats(MemoryContext context, Size size)
{
    if (context->stats)
    {
        if (!context->isShared)
        {
            sMonAdd(memory_context_statsTotalBackendAllocated_Size,  size);
            sMonHWM(memory_context_statsTotalBackendAllocated_HWM,
                    sMonGet(memory_context_stats, TotalBackendAllocated_Size));
            context->allocatedSize += size;
            context->stats[0] += size;
            context->stats[1] = (context->stats[1] >= context->stats[0] ?
                                        context->stats[1] : context->stats[0]);
        }
        else
        {
            if (!context->isNested)
                size += SHM_BLOCK_OVERHEAD;
 
            sAtomicAdd(&context->allocatedSize, size);
 
            if (!context->isNested ||
                !context->clusterrep ||
                context->clusterrep->stats != context->stats)
                sAtomicAdd(context->stats, size);
        }
    }
}

 
I'll try myself on peeling out a patch for community for the stats and ask he developer responsible for hash spilling to engage.
 
Cheers
Serge
 
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: why partition pruning doesn't work?
Следующее
От: David Fetter
Дата:
Сообщение: Re: Spilling hashed SetOps and aggregates to disk