Re: Dropping a partitioned table takes too long

From: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
To: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Dropping a partitioned table takes too long
Date: 2017-04-25 11:55:45
Message-ID: CAFjFpRcCLRxh=3aQrS3OE92Oh7yD_fxqiiGR_N_i8K8_Q7XwKQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Apr 25, 2017 at 12:37 PM, Amit Langote
<Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> wrote:
> $SUBJECT, if the table has, say, 2000 partitions.
>
> The main reason seems to be that RelationBuildPartitionDesc() will be
> called that many times within the same transaction, which perhaps we
> cannot do much about right away. But one thing we could do is to reduce
> the impact of memory allocations it does. They are currently leaked into
> the caller's context, which may not be reset immediately (such as
> PortalHeapMemory). Instead of doing it in the caller's context, use a
> temporary context that is deleted before returning. Attached is a patch
> for that. On my local development VM, `drop table
> table_with_2000_partitions` finished in 27 seconds with the patch instead
> of more than 20 minutes that it currently takes.
>
> Thoughts?
>
I am not able to undestand why does changing memory context cause so
much difference in execution time?

The way this patch uses the memory context in this patch, it's
possible that in future we will allocate something in temporary
context and then refer it from a longer context. Instead, may be we
should free things specially or change memory context only when
allocating those things.
--
Best Wishes,
Ashutosh Bapat
EnterpriseDB Corporation
The Postgres Database Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2017-04-25 12:18:16 Re: OK, so culicidae is *still* broken
Previous Message Ashutosh Bapat 2017-04-25 11:22:04 Re: Partition-wise join for join between (declaratively) partitioned tables