On Thu, 16 May 2019 at 05:44, Peter Eisentraut <peter.eisentr...@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