重庆思庄Oracle、Redhat认证学习论坛
标题:
PG模糊查看参数情况
[打印本页]
作者:
郑全
时间:
2024-8-4 13:23
标题:
PG模糊查看参数情况
本帖最后由 郑全 于 2024-8-4 13:29 编辑
我们知道,在ORACLE数据库中,记不太清某个参数,但知道包含某部分字符时,可以使用 show parameter target看到包含target 的参数情况,MYSQL可以使用 show variables like '%dir%';那么,在pg中,能否实现呢 ?
比如想看看包含 dir 的参数:
show dir ,会报错:
cis=# show dir;
ERROR: unrecognized configuration parameter "dir"
cis=#
cis=# show '%dir%';
ERROR: syntax error at or near "'%dir%'"
LINE 1: show '%dir%';
^
cis=#
看来简单的一个show 不行,遇到这种情况,我们一般使用SQL语句搞定
cis=# select name,setting from pg_settings where name like '%dir%';
name | setting
-------------------------+------------------------
data_directory | /var/lib/pgsql/16/data
data_directory_mode | 0700
debug_io_direct |
log_directory | pg_log
ssl_crl_dir |
unix_socket_directories | /var/lib/pgsql/16/data
vacuum_cost_page_dirty | 20
(7 rows)
cis=#
是否真的只有SQL才能搞定吗?
其实,PG也可以使用 ,不过,要从PG15开始,增加了一个新的元命令 DCONFIG
比如上面这个模糊查看功能
\dconfig *dir*
postgres=# \dconfig *dir*
List of configuration parameters
Parameter | Value
-------------------------+------------------------
data_directory | /var/lib/pgsql/16/data
data_directory_mode | 0700
debug_io_direct |
log_directory | pg_log
ssl_crl_dir |
unix_socket_directories | /var/lib/pgsql/16/data
vacuum_cost_page_dirty | 20
(7 rows)
postgres=# \dconfig log*
List of configuration parameters
Parameter | Value
-----------------------------------+-------------------
log_autovacuum_min_duration | 10min
log_checkpoints | on
log_connections | off
log_destination | stderr
log_directory | pg_log
log_disconnections | off
log_duration | off
log_error_verbosity | default
log_executor_stats | off
log_file_mode | 0600
log_filename | postgresql-%a.log
log_hostname | off
log_line_prefix | %m [%p]
log_lock_waits | off
log_min_duration_sample | -1
log_min_duration_statement | -1
log_min_error_statement | error
log_min_messages | warning
log_parameter_max_length | -1
log_parameter_max_length_on_error | 0
log_parser_stats | off
log_planner_stats | off
log_recovery_conflict_waits | off
log_replication_commands | off
log_rotation_age | 1d
log_rotation_size | 0
log_startup_progress_interval | 10s
log_statement | none
log_statement_sample_rate | 1
log_statement_stats | off
log_temp_files | -1
log_timezone | Asia/Shanghai
log_transaction_sample_rate | 0
log_truncate_on_rotation | on
logging_collector | on
logical_decoding_work_mem | 64MB
(36 rows)
postgres=# \dconfig *size
List of configuration parameters
Parameter | Value
------------------------------+-------
block_size | 8192
effective_cache_size | 4GB
geqo_pool_size | 0
huge_page_size | 0
log_rotation_size | 0
max_slot_wal_keep_size | -1
max_wal_size | 1GB
min_parallel_index_scan_size | 512kB
min_parallel_table_scan_size | 8MB
min_wal_size | 80MB
segment_size | 1GB
shared_memory_size | 143MB
track_activity_query_size | 1kB
wal_block_size | 8192
wal_decode_buffer_size | 512kB
wal_keep_size | 0
wal_segment_size | 16MB
(17 rows)
postgres=# \dconfig *name*
List of configuration parameters
Parameter | Value
---------------------------+-------------------
application_name | psql
bonjour_name |
cluster_name |
db_user_namespace | off
log_filename | postgresql-%a.log
log_hostname | off
primary_slot_name |
recovery_target_name |
synchronous_standby_names |
(9 rows)
欢迎光临 重庆思庄Oracle、Redhat认证学习论坛 (http://bbs.cqsztech.com/)
Powered by Discuz! X3.2