Re: maintenance_work_mem and CREATE INDEX time

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: maintenance_work_mem and CREATE INDEX time
Date: 2013-07-24 05:56:31
Message-ID: CA+HiwqG-mtKqXAc24bQmHBFUjAddUfxjBcjVq2yk-yebjGr0OA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Wed, Jul 24, 2013 at 3:20 AM, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
> On Mon, Jul 22, 2013 at 9:11 PM, Amit Langote <amitlangote09(at)gmail(dot)com> wrote:
>> Hello,
>>
>> While understanding the effect of maintenance_work_mem on time taken
>> by CREATE INDEX, I observed that for the values of
>> maintenance_work_mem less than the value for which an internal sort is
>> performed, the time taken by CREATE INDEX increases as
>> maintenance_work_increases.
>>
>> My guess is that for all those values an external sort is chosen at
>> some point and larger the value of maintenance_work_mem, later the
>> switch to external sort would be made causing CREATE INDEX to take
>> longer. That is a smaller value of maintenance_work_mem would be
>> preferred for when external sort is performed anyway. Does that make
>> sense?
>
> The heap structure used in external sorts is cache-unfriendly. The
> bigger the heap used, the more this unfriendliness becomes apparent.
> And the bigger maintenance_work_mem, the bigger the heap used.
>
> The bigger heap also means you have fewer "runs" to merge in the
> external sort. However, as long as the number of runs still fits in
> the same number of merge passes, this is generally not a meaningful
> difference.

Does fewer runs mean more time (in whichever phase of external sort)?

--
Amit Langote

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Luca Ferrari 2013-07-24 07:10:28 Re: Why are stored procedures looked on so negatively?
Previous Message Albe Laurenz 2013-07-24 05:04:08 Re: Why are stored procedures looked on so negatively?

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2013-07-24 06:07:46 Re: Performance problem in PLPgSQL
Previous Message Amit Kapila 2013-07-24 05:06:18 Re: ALTER SYSTEM SET command to change postgresql.conf parameters (RE: Proposal for Allow postgresql.conf values to be changed via SQL [review])