Re: Time to run initdb is mostly figure-out-the-timezone work

From: Guillaume Lelarge <guillaume(at)lelarge(dot)info>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Time to run initdb is mostly figure-out-the-timezone work
Date: 2009-12-18 17:20:39
Message-ID: 4B2BB9E7.9020406@lelarge.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Le 18/12/2009 18:07, Tom Lane a écrit :
> On current Fedora 11, there is a huge difference in initdb time if you
> have TZ set versus if you don't: I get about 18 seconds versus less than
> four.
>
> $ time initdb
> ... blah blah blah ...
>
> real 0m17.953s
> user 0m6.490s
> sys 0m10.935s
> $ rm -rf $PGDATA
> $ export TZ=GMT
> $ time initdb
> ... blah blah blah ...
>
> real 0m3.767s
> user 0m2.997s
> sys 0m0.784s
> $
>
> The reason for this is that initdb launches the postmaster many times
> (at least 14) and each one of those launches results in a search of
> every file in the timezone database, if we don't have a TZ value to
> let us identify the timezone immediately.
>
> Now this hardly matters to end users who seldom do initdb, but from a
> developer's perspective it would be awfully nice if initdb took less
> time. If other people can reproduce similar behavior, I think it
> would be worth the trouble to have initdb forcibly set the TZ or PGTZ
> variable while it runs.

I have the exact same issue:

guillaume(at)laptop:~$ time initdb
Les fichiers de ce cluster appartiendront à l'utilisateur « guillaume ».
[...]
real 0m7.972s
user 0m3.588s
sys 0m3.444s
guillaume(at)laptop:~$ export TZ=GMT
guillaume(at)laptop:~$ rm -rf t1
guillaume(at)laptop:~$ time initdb
[...]
real 0m1.828s
user 0m1.436s
sys 0m0.368s

This is on Ubuntu 9.10.

Quite impressive. I think I'll add an alias (alias initdb="TZ=GMT initdb").

--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Florian Pflug 2009-12-18 17:22:34 Re: Backup history file should be replicated in Streaming Replication?
Previous Message Florian Pflug 2009-12-18 17:15:20 Re: Update on true serializable techniques in MVCC