- Notifications
You must be signed in to change notification settings - Fork28
Commitc521d5a
committed
Improve performance of timezone loading, especially pg_timezone_names view.
tzparse() would attempt to load the "posixrules" timezone database file oneach call. That might seem like it would only be an issue when selecting aPOSIX-style zone name rather than a zone defined in the timezone database,but it turns out that each zone definition file contains a POSIX-style zonestring and tzload() will call tzparse() to parse that. Thus, when scanningthe whole timezone file tree as we do in the pg_timezone_names view,"posixrules" was read repetitively for each zone definition file. Fixthat by caching the file on first use within any given process. (We cacheother zone definitions for the life of the process, so there seems littlereason not to cache this one as well.) This probably won't help much inprocesses that never run pg_timezone_names, but even one additional SETof the timezone GUC would come out ahead.An even worse problem for pg_timezone_names is that pg_open_tzfile()has an inefficient way of identifying the canonical case of a zone name:it basically re-descends the directory tree to the zone file. That's notawful for an individual "SET timezone" operation, but it's pretty horridwhen we're inspecting every zone in the database. And it's pointless toobecause we already know the canonical spelling, having just read it fromthe filesystem. Fix by teaching pg_open_tzfile() to avoid the directorysearch if it's not asked for the canonical name, and backfilling theproper result in pg_tzenumerate_next().In combination these changes seem to make the pg_timezone_names viewabout 3x faster to read, for me. Since a scan of pg_timezone_nameshas up to now been one of the slowest queries in the regression tests,this should help some little bit for buildfarm cycle times.Back-patch to all supported branches, not so much because it's likelythat users will care much about the view's performance as becausetracking changes in the upstream IANA timezone code is really painfulif we don't keep all the branches in sync.Discussion:https://postgr.es/m/27962.1493671706@sss.pgh.pa.us1 parentd56b8b4 commitc521d5a
3 files changed
+60
-8
lines changedLines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
79 | 79 |
| |
80 | 80 |
| |
81 | 81 |
| |
| 82 | + | |
| 83 | + | |
| 84 | + | |
82 | 85 |
| |
83 | 86 |
| |
84 | 87 |
| |
|
Lines changed: 22 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
57 | 64 |
| |
58 | 65 |
| |
59 | 66 |
| |
| |||
942 | 949 |
| |
943 | 950 |
| |
944 | 951 |
| |
945 |
| - | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
946 | 967 |
| |
947 | 968 |
| |
948 | 969 |
| |
|
Lines changed: 35 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
80 | 80 |
| |
81 | 81 |
| |
82 | 82 |
| |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
83 | 110 |
| |
84 | 111 |
| |
85 | 112 |
| |
86 | 113 |
| |
87 |
| - | |
88 |
| - | |
89 | 114 |
| |
90 | 115 |
| |
91 | 116 |
| |
| |||
97 | 122 |
| |
98 | 123 |
| |
99 | 124 |
| |
100 |
| - | |
101 |
| - | |
102 | 125 |
| |
103 | 126 |
| |
104 | 127 |
| |
| |||
458 | 481 |
| |
459 | 482 |
| |
460 | 483 |
| |
461 |
| - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
462 | 487 |
| |
463 |
| - | |
464 |
| - | |
| 488 | + | |
465 | 489 |
| |
466 | 490 |
| |
467 | 491 |
| |
| |||
473 | 497 |
| |
474 | 498 |
| |
475 | 499 |
| |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
476 | 504 |
| |
477 | 505 |
| |
478 | 506 |
| |
|
0 commit comments
Comments
(0)