Skip to content

SELECT name FROM pg_timezone_names; has variable performance, affecting startup time #5100

Description

@steve-chavez

Problem

This on an AWS instance (always north of 700 ms):

systemctl restart postgres; time psql-d postgres -c "SELECT name FROM pg_timezone_names" >> /dev/null;

real    0m0.815s
user    0m0.012s
sys     0m0.009s
systemctl restart postgres; time psql-d postgres -c "SELECT name FROM pg_timezone_names" >> /dev/null;

real    0m0.958s
user    0m0.008s
sys     0m0.011s
systemctl restart postgres; time psql-d postgres -c "SELECT name FROM pg_timezone_names" >> /dev/null;

real    0m0.775s
user    0m0.011s
sys     0m0.012s
systemctl restart postgres; time psql-d postgres -c "SELECT name FROM pg_timezone_names" >> /dev/null;

real    0m0.964s
user    0m0.010s
sys     0m0.009s

Locally:

systemctl restart postgres; time psql -d postgres -c "SELECT name FROM pg_timezone_names" >> /dev/null;

real    0m0.060s
user    0m0.006s
sys     0m0.003s

systemctl restart postgres; time psql -d postgres -c "SELECT name FROM pg_timezone_names" >> /dev/null;

real    0m0.060s
user    0m0.006s
sys     0m0.000s

systemctl restart postgres; time psql -d postgres -c "SELECT name FROM pg_timezone_names" >> /dev/null;

real    0m0.062s
user    0m0.006s
sys     0m0.005s

As previously mentioned on #4751 (comment), pg_timezone_names actually does a lookup on the filesystem. This varies: can be slow when using network storage, can be fast on local NVMe.

Another problem is that this is not a common use case and can be done in other ways:

The thing is that timezone is a special use case, not everyone needs it. As per #2799, it can already be done via roles. On hindsight it was a mistake adding it without a config flag, it should have been done like Prefer: tx.
#4751 (comment)

Solution

Switch to db-timezone-enabled = false by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeA bug fix or enhancement that would cause a breaking changeconfigrelated to the configuration optionsperf

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions