We have noticed a severe decrease in performance reading pg_catalog.pg_settings table in PostgreSQL 12 on MS Windows 10 machines compared to earlier versions.
explain (analyze, buffers, timing)
SELECT * from pg_catalog.pg_settings where name =
'standard_conforming_strings';
On PostgreSQL 12.5, compiled by Visual C++ build 1914, 64-bit:
Function Scan on pg_show_all_settings a (cost=0.00..12.50 rows=5
width=485) (actual time=343.350..343.356 rows=1 loops=1)
Filter: (name = 'standard_conforming_strings'::text)
Rows Removed by Filter: 313
Planning Time: 0.079 ms
Execution Time: 343.397 ms
Compare to PostgreSQL 11.13, compiled by Visual C++ build 1914, 64-bit:
Function Scan on pg_show_all_settings a (cost=0.00..12.50 rows=5
width=485) (actual time=0.723..0.728 rows=1 loops=1)
Filter: (name = 'standard_conforming_strings'::text)
Rows Removed by Filter: 289
Planning Time: 0.125 ms
Execution Time: 0.796 ms
This is standard installation, the changed parameters are:
SELECT name, current_setting(name), source
FROM pg_settings
WHERE source NOT IN ('default', 'override');
name | current_setting | source |
---|---|---|
client_encoding | UTF8 | client |
DateStyle | ISO, YMD | client |
default_text_search_config | pg_catalog.simple | session |
default_transaction_isolation | read committed | session |
dynamic_shared_memory_type | windows | configuration file |
extra_float_digits | 3 | session |
lc_messages | Lithuanian_Lithuania.1257 | configuration file |
lc_monetary | Lithuanian_Lithuania.1257 | configuration file |
lc_numeric | Lithuanian_Lithuania.1257 | configuration file |
lc_time | Lithuanian_Lithuania.1257 | configuration file |
listen_addresses | * | configuration file |
log_destination | stderr | configuration file |
log_file_mode | 0640 | configuration file |
log_timezone | Europe/Helsinki | configuration file |
logging_collector | on | configuration file |
max_connections | 100 | configuration file |
max_stack_depth | 2MB | environment variable |
max_wal_size | 1GB | configuration file |
min_wal_size | 80MB | configuration file |
port | 5444 | configuration file |
search_path | "$user", public | session |
shared_buffers | 128MB | configuration file |
TimeZone | Europe/Helsinki | client |
The slowing down is observed on MS Windows 10 machines only. We have pg12 on linux (PostgreSQL 12.6 (Debian 12.6-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit ) that doesn't show any decrease in performance.
I've tested different versions and it seems the problem appeared on PG12,
earlier versions up to PG11 work ok. PG13 also suffers from low reading
speed of pg_settings
.
The behaviour is reproduced on 3 different machines (2 virtual and one physical, different hardware).
What is the cause of this? How to fix the issue?
I've found a similar question Select from pg_settings is very slow but it still has no answer too.
UPDATE
I've tested PostgreSQL 14 - there is a noticible performance increase. PostgreSQL 14.0, compiled by Visual C++ build 1914, 64-bit:
Function Scan on pg_show_all_settings a (cost=0.00..12.50 rows=5 width=485) (actual time=8.502..8.508 rows=1 loops=1)
Filter: (name = 'standard_conforming_strings'::text)
Rows Removed by Filter: 343
Planning:
Buffers: shared hit=18
Planning Time: 0.224 ms
Execution Time: 8.555 ms
It is still 10 times slower than the PostgreSQL 11.13 but 40 times faster than the Pg12.
EDIT 2
As noticed by a_horse_with_no_name we don't observe performance problems when using querying current_setting
.
explain (analyze, buffers, timing)
select current_setting('standard_conforming_strings');
returns:
Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.007..0.008 rows=1 loops=1)
Planning Time: 0.025 ms
Execution Time: 0.022 ms
I've posted the question to the pgsql-performance
mailing list and got an answer from Ranier Vilela that updating to latest version of PostgreSQL (v12.8.2) should fix the problem.
He directed me to a message thread discussing the issue. It seems the problem was in libintl
library and is now fixed.