Re: Ought to use heap_multi_insert() for pg_attribute/dependinsertions? - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Ought to use heap_multi_insert() for pg_attribute/dependinsertions?
Date
Msg-id 20190523014613.zpoj2wbwt22bbi43@alap3.anarazel.de
Whole thread Raw
In response to Re: Ought to use heap_multi_insert() for pg_attribute/dependinsertions?  (Daniel Gustafsson <daniel@yesql.se>)
Responses Re: Ought to use heap_multi_insert() for pg_attribute/dependinsertions?
Re: Ought to use heap_multi_insert() for pg_attribute/dependinsertions?
List pgsql-hackers
Hi,

On 2019-05-22 10:25:14 +0200, Daniel Gustafsson wrote:
> > On 13 Feb 2019, at 19:27, Andres Freund <andres@anarazel.de> wrote:
> > 
> > Hi,
> > 
> > Turns out in portions of the regression tests a good chunk of the
> > runtime is inside AddNewAttributeTuples() and
> > recordMultipleDependencies()'s heap insertions. Looking at a few
> > profiles I had lying around I found that in some production cases
> > too. ISTM we should use heap_multi_insert() for both, as the source
> > tuples ought to be around reasonably comfortably.
> > 
> > For recordMultipleDependencies() it'd obviously better if we collected
> > all dependencies for new objects, rather than doing so separately. Right
> > now e.g. the code for a new table looks like:
> > 
> >         recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
> > 
> >         recordDependencyOnOwner(RelationRelationId, relid, ownerid);
> > 
> >         recordDependencyOnNewAcl(RelationRelationId, relid, 0, ownerid, relacl);
> > 
> >         recordDependencyOnCurrentExtension(&myself, false);
> > 
> >         if (reloftypeid)
> >         {
> >             referenced.classId = TypeRelationId;
> >             referenced.objectId = reloftypeid;
> >             referenced.objectSubId = 0;
> >             recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
> >         }
> > 
> > and it'd obviously be more efficient to do that once if we went to using
> > heap_multi_insert() in the dependency code. But I suspect even if we
> > just used an extended API in AddNewAttributeTuples() (for the type /
> > collation dependencies), it'd be a win.
> 
> When a colleague was looking at heap_multi_insert in the COPY codepath I
> remembered this and took a stab at a WIP patch inspired by this email, while
> not following it to the letter.  It’s not going the full route of collecting
> all the dependencies for creating a table, but adding ways to perform
> multi_heap_insert in the existing codepaths as it seemed like a good place to
> start.

Cool. I don't quite have the energy to look at this right now, could you
create a CF entry for this?

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Haribabu Kommi
Date:
Subject: Re: MSVC Build support with visual studio 2019
Next
From: Michael Paquier
Date:
Subject: Re: ACL dump ordering broken as well for tablespaces