Re: Why does ExecComputeStoredGenerated() form a heap tuple - Mailing list pgsql-hackers

From David Rowley
Subject Re: Why does ExecComputeStoredGenerated() form a heap tuple
Date
Msg-id CAKJS1f_Kok0S5i2kOQHU8z_eZ6oZr=PG-WKofUiM=J0oD0HQ8A@mail.gmail.com
Whole thread Raw
In response to Re: Why does ExecComputeStoredGenerated() form a heap tuple  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: Why does ExecComputeStoredGenerated() form a heap tuple  (Andres Freund <andres@anarazel.de>)
Re: Why does ExecComputeStoredGenerated() form a heap tuple  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-hackers
On Thu, 16 May 2019 at 05:44, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
> Updated patch attached.

This patch looks okay to me.

It's not for this patch, or probably for PG12, but it would be good if
we could avoid the formation of the Tuple until right before the new
tuple is inserted.

I see heap_form_tuple() is called 3 times for a single INSERT with:

create table t (a text, b text, c text generated always as (b || b) stored);

create or replace function t_trigger() returns trigger as $$
begin
NEW.b = UPPER(NEW.a);
RETURN NEW;
end;
$$ language plpgsql;

create trigger t_on_insert before insert on t for each row execute
function t_trigger();

insert into t (a) values('one');

and heap_deform_tuple() is called once for each additional
heap_form_tuple().  That's pretty wasteful :-(

Maybe Andres can explain if this is really required, or if it's just
something that's not well optimised yet.

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Calling PrepareTempTablespaces in BufFileCreateTemp
Next
From: Masahiko Sawada
Date:
Subject: Re: New vacuum option to do only freezing