Re: [HACKERS] Dropping a partitioned table takes too long - Mailing list pgsql-hackers

From Ashutosh Bapat
Subject Re: [HACKERS] Dropping a partitioned table takes too long
Date
Msg-id CAFjFpRcCLRxh=3aQrS3OE92Oh7yD_fxqiiGR_N_i8K8_Q7XwKQ@mail.gmail.com
Whole thread Raw
In response to [HACKERS] Dropping a partitioned table takes too long  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
Responses Re: [HACKERS] Dropping a partitioned table takes too long  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
List pgsql-hackers
On Tue, Apr 25, 2017 at 12:37 PM, Amit Langote
<Langote_Amit_f8@lab.ntt.co.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



pgsql-hackers by date:

Previous
From: Ashutosh Bapat
Date:
Subject: Re: [HACKERS] Partition-wise join for join between (declaratively)partitioned tables
Next
From: Craig Ringer
Date:
Subject: Re: [HACKERS] OK, so culicidae is *still* broken