Re: Why does ExecComputeStoredGenerated() form a heap tuple

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Why does ExecComputeStoredGenerated() form a heap tuple
Дата
Msg-id CAKJS1f_Kok0S5i2kOQHU8z_eZ6oZr=PG-WKofUiM=J0oD0HQ8A@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Why does ExecComputeStoredGenerated() form a heap tuple  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Ответы 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>)
Список 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 по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: Calling PrepareTempTablespaces in BufFileCreateTemp
Следующее
От: Masahiko Sawada
Дата:
Сообщение: Re: New vacuum option to do only freezing