Re: Bootstrap DATA is a pita - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Bootstrap DATA is a pita
Date
Msg-id 20150221230839.GE2037@awork2.anarazel.de
Whole thread Raw
In response to Re: Bootstrap DATA is a pita  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: Bootstrap DATA is a pita  (Greg Stark <stark@mit.edu>)
List pgsql-hackers
On 2015-02-21 17:43:09 +0100, Andres Freund wrote:
> One thing I was considering was to do the regtype and regproc lookups
> directly in the tool. That'd have two advantages: 1) it'd make it
> possible to refer to typenames in pg_proc, 2) It'd be much faster. Right
> now most of initdb's time is doing syscache lookups during bootstrap,
> because it can't use indexes... A simple hash lookup during bki
> generation could lead to quite measurable savings during lookup.

I've *very* quickly hacked this up. Doing this for all regproc columns
gives a consistent speedup in an assert enabled from ~0m3.589s to
~0m2.544s. My guess is that the relative speedup in optimized mode would
actually be even bigger as now most of the time is spent in
AtEOXact_CatCache.

Given that pg_proc is unlikely to get any smaller and that the current
code is essentially O(lookups * #pg_proc), this alone seems to be worth
a good bit.

The same trick should also allow us to simply refer to type names in
pg_proc et al. If we had a way to denote a column being of type
relnamespace/relauthid we could replace
    $row->{bki_values} =~ s/\bPGUID\b/$BOOTSTRAP_SUPERUSERID/g;
    $row->{bki_values} =~ s/\bPGNSP\b/$PG_CATALOG_NAMESPACE/g;
as well.

The changes in pg_proc.h are just to demonstrate that using names
instead of oids works.

Greetings,

Andres Freund

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

Attachment

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Abbreviated keys for Numeric
Next
From: Tom Lane
Date:
Subject: Re: Precedence of standard comparison operators