Re: Parallelizing startup with many databases

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andreas Karlsson <andreas(at)proxel(dot)se>
Cc: Babak Ghadiri <bbkghadiri6(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Parallelizing startup with many databases
Date: 2026-01-03 00:02:27
Message-ID: 290550.1767398547@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-hackers

Andreas Karlsson <andreas(at)proxel(dot)se> writes:
> On 1/2/26 8:55 AM, Babak Ghadiri wrote:
>> In PostgreSQL 16, startup appears to initialize databases sequentially and
>> primarily uses a single CPU core. In clusters with a very large number of
>> databases (around 5,000 in our case), this results in noticeably long
>> startup times after restarts or crash recovery.

> Have you measured what is actually causing the slow startup? Without
> knowing what is actually slow it is hard to say if threading would even
> help.

"perf" results would likely be useful.

I tried creating 5000 databases here and didn't notice any particular
increase in server startup time (didn't try crash-recovery case).
So whatever this is is likely somewhat configuration- or
platform-dependent.

Having said that, 5000 databases sounds like an anti-pattern to
begin with. You're paying for an additional copy of the system
catalogs for each one.

regards, tom lane

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message Jelte Fennema-Nio 2026-01-03 00:58:25 Re: Parallelizing startup with many databases
Previous Message Andreas Karlsson 2026-01-02 23:38:10 Re: Parallelizing startup with many databases

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Karlsson 2026-01-03 00:24:56 Re: [Proposal] Generate pkg-config for server module development
Previous Message Andreas Karlsson 2026-01-02 23:38:10 Re: Parallelizing startup with many databases