Re: Do we really need to switch to per-tuple memory context in ATRewriteTable() when Table Rewrite is not happening

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Do we really need to switch to per-tuple memory context in ATRewriteTable() when Table Rewrite is not happening
Date: 2018-01-03 13:55:35
Message-ID: 20180103135535.otpmygpffiwnhqdi@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ashutosh Sharma wrote:

> I am basically talking about the following lines of code in
> ATRewriteTable() function.
>
> /*
> * Switch to per-tuple memory context and reset it for each tuple
> * produced, so we don't leak memory.
> */
> oldCxt = MemoryContextSwitchTo(GetPerTupleMemoryContext(estate));

Perhaps a memory context switch is so cheap that adding a branch to
verify whether it's needed is more expensive than just doing it all the
time. You could prove me wrong by measuring it.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2018-01-03 14:28:02 Re: Deadlock in multiple CIC.
Previous Message David Rowley 2018-01-03 13:52:24 Re: [HACKERS] UPDATE of partition key