Re: Space management for PGresult

Поиск
Список
Период
Сортировка
От Atsushi Ogawa
Тема Re: Space management for PGresult
Дата
Msg-id 613787150511240448l5f159206n@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Space management for PGresult  (Alvaro Herrera <alvherre@commandprompt.com>)
Ответы Re: Space management for PGresult  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-patches
Alvaro Herrera wrote:
> Tom Lane wrote:
> > Atsushi Ogawa <atsushi.ogawa@gmail.com> writes:
> > > The number of malloc calls at pqResultAlloc:
> > >  8.1.0  : 80542
> > >  patched:    86
> >
> > > Execution time:
> > >  8.1.0  : 6.80 sec
> > >  patched: 6.73 sec
> >
> > This hardly seems worth adding any complexity for ...
>
> What about memory usage?  Is there a notorious difference?

Well, I measured memory usage by attached patch. An allocated(bytes)
is total amounts of allocated memory by pqResultAlloc. An unused(bytes)
is total amounts of PGresult->spaceLeft.

(1)accounts table (4 columns, 1,000,000 tuples)
          malloc calls   allocated(bytes)   unused(bytes)  execution time
--------------------------------------------------------------------------
8.1.0           80,542        164,950,016       2,946,402       6.80 sec.
patched             86        161,478,656         177,650       6.73 sec.

(2)another teble (50 columns, 100,000 tuples)
          malloc calls   allocated(bytes)   unused(bytes)  execution time
--------------------------------------------------------------------------
8.1.0           55,557        113,780,736       8,561,518       6.26 sec.
patched             86        104,855,552          83,307       6.21 sec.

The unused memory increases when the number of columns increases. The
tuple size of PGresult is proportional to the number of columns.

getAnotherTuple() at fe-protocol3.c:
--------------------------------------------------------------------------
        conn->curTuple = (PGresAttValue *)
            pqResultAlloc(result, nfields * sizeof(PGresAttValue), TRUE);
--------------------------------------------------------------------------

regards,

--- Atsushi Ogawa

Вложения

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Space management for PGresult
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: [PATCH] Formatting patch for psql