‘show parameter ‘ for openGauss or PostgreSQL

本文涉及的产品
云原生数据库 PolarDB MySQL 版,Serverless 5000PCU 100GB
云原生数据库 PolarDB PostgreSQL 版,企业版 4核16GB
推荐场景:
HTAP混合负载
云原生数据库 PolarDB MySQL 版,通用型 2核4GB 50GB
简介: 对于oracle DBA查看数据库实例参数可以在sqlplus中使用show prameter xxx 模糊匹配非隐藏参数或已修改隐藏参数,当然也可以查询v$ 的视图, 在openGauss或postgresql当前版本中需要匹配输入参数名,当然参数名我们不可能完全记的全名,模糊搜索需要手动创建个shell方法。

对于oracle DBA查看数据库实例参数可以在sqlplus中使用show prameter xxx 模糊匹配非隐藏参数或已修改隐藏参数,当然也可以查询v$ 的视图, 在openGauss或postgresql当前版本中需要匹配输入参数名,当然参数名我们不可能完全记的全名,模糊搜索需要手动创建个shell方法。

在postgresql中查看参数的几个方法

1, show all

Displays the current setting of run-time parameters,也就是运行时当前的参数。只有3列,也可以指定具体的参数值。相当于oracle sqlplus的show parameter ,在og/pg通用

openGauss=# show all;


openGauss=# show autovacuum;

autovacuum

------------

on

(1 row)


openGauss=# show autovac;

ERROR:  unrecognized configuration parameter "autovac"



2, pg_settings

显示结果和show all相同, 只不过pg_settings view显示的列更多,等同于oracle的v$parameter, 在og/pg通用。

openGauss=# select * from pg_settings;



3, pg_file_settings

该view pg_file_settings.查询的是postgresql.conf配置文件的内容。 相当于oracle的v$spparameter, 这是目前postgresql有,而opengauss还没有的view.

[local]:5432 postgres@postgres=# TABLE pg_file_settings;

                     sourcefile                       | sourceline | seqno |            name            |                  setting                   | applied | error

-------------------------------------------------------+------------+-------+----------------------------+--------------------------------------------+---------+-------

/opensource/postgreSQL/13.2/data/postgresql.conf      |         60 |     1 | listen_addresses           | *                                          | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |         64 |     2 | port                       | 5432                                       | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |         66 |     3 | max_connections            | 100                                        | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        123 |     4 | shared_buffers             | 128MB                                      | f       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        144 |     5 | dynamic_shared_memory_type | posix                                      | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        230 |     6 | max_wal_size               | 1GB                                        | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        231 |     7 | min_wal_size               | 80MB                                       | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        565 |     8 | log_timezone               | America/New_York                           | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        680 |     9 | datestyle                  | iso, mdy                                   | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        683 |    10 | timezone                   | Asia/Shanghai                              | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        684 |    11 | orafce.timezone            | PRC                                        | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        698 |    12 | lc_messages                | C                                          | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        700 |    13 | lc_monetary                | C                                          | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        701 |    14 | lc_numeric                 | C                                          | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        702 |    15 | lc_time                    | C                                          | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        705 |    16 | default_text_search_config | pg_catalog.english                         | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        785 |    17 | shared_preload_libraries   | pg_stat_statements,pgsentinel,pg_hint_plan | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        787 |    18 | track_activity_query_size  | 2048                                       | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        789 |    19 | pg_stat_statements.track   | all                                        | t       |

/opensource/postgreSQL/13.2/data/postgresql.conf      |        790 |    20 | pg_stat_statements.max     | 10000                                      | t       |

/opensource/postgreSQL/13.2/data/postgresql.auto.conf |          3 |    21 | log_rotation_age           | 10081                                      | t       |

/opensource/postgreSQL/13.2/data/postgresql.auto.conf |          4 |    22 | logging_collector          | on                                         | t       |

/opensource/postgreSQL/13.2/data/postgresql.auto.conf |          5 |    23 | log_destination            | stderr                                     | t       |

/opensource/postgreSQL/13.2/data/postgresql.auto.conf |          6 |    24 | log_statement              | none                                       | t       |

/opensource/postgreSQL/13.2/data/postgresql.auto.conf |          7 |    25 | shared_buffers             | 256MB                                      | t       |

(25 rows)



BTW: 在postgresql系中, table xxx相当于select * from xxx;

我们如果想直接和oracle sqlplus一样模糊搜索,可以搞一个shell 为了美化可以使用AWR 实例ltrim 和substr 截取长度或删除尾部空格。

sub(/^[[:blank:]]*/,””,变量) 是去掉变量左边的空白符

sub(/[[:blank:]]*$/,””,变量) 是去掉变量右边的空白符

gsub(/[[:blank:]]*/,””,变量) 是去掉变量中所有的空白符

自己搞个shell

openGauss=# \! sh show vacuum

autovacuum                             | on                 | Starts the autovacuum subprocess.

autovacuum_analyze_scale_factor        | 0.1                | Number of tuple inserts, updates, or deletes prior to analyze as a fraction of reltuples.

autovacuum_analyze_threshold           | 50                 | Minimum number of tuple inserts, updates, or deletes prior to analyze.

autovacuum_freeze_max_age              | 4000000000         | Age at which to autovacuum a table.

autovacuum_io_limits                   | -1                 | Sets io_limit for autovacum.

autovacuum_max_workers                 | 3                  | Sets the maximum number of simultaneously running autovacuum worker processes.

autovacuum_mode                        | mix                | Sets the behavior of autovacuum

autovacuum_naptime                     | 10min              | Time to sleep between autovacuum runs.

autovacuum_vacuum_cost_delay           | 20ms               | Vacuum cost delay in milliseconds, for autovacuum.

autovacuum_vacuum_cost_limit           | -1                 | Vacuum cost amount available before napping, for autovacuum.

autovacuum_vacuum_scale_factor         | 0.2                | Number of tuple updates or deletes prior to vacuum as a fraction of reltuples.

autovacuum_vacuum_threshold            | 50                 | Minimum number of tuple updates or deletes prior to vacuum.

enable_debug_vacuum                    | off                | This parameter is just used for logging some vacuum info.

log_autovacuum_min_duration            | -1                 | Sets the minimum execution time above which autovacuum actions will be logged.

vacuum_cost_delay                      | 0                  | Vacuum cost delay in milliseconds.

vacuum_cost_limit                      | 200                | Vacuum cost amount available before napping.

vacuum_cost_page_dirty                 | 20                 | Vacuum cost for a page dirtied by vacuum.

vacuum_cost_page_hit                   | 1                  | Vacuum cost for a page found in the buffer cache.

vacuum_cost_page_miss                  | 10                 | Vacuum cost for a page not found in the buffer cache.

vacuum_defer_cleanup_age               | 0                  | Number of transactions by which VACUUM and HOT cleanup should be deferred, if any.

vacuum_freeze_min_age                  | 2000000000         | Minimum age at which VACUUM should freeze a table row.

vacuum_freeze_table_age                | 4000000000         | Age at which VACUUM should scan whole table to freeze tuples.

vacuum_gtt_defer_check_age             | 10000              | The defer check age of GTT, used to check expired data after vacuum.

openGauss=#


[og@oel7db1 ~]$ cat show

#!/bin/bash

# author: weizhao zhang(anbob.com)

gsql -d postgres -p 5432 -c 'show all;'|grep "$1"|awk -F"|" '{ sub(/[[:blank:]]*$/,"",$3);print  substr($1,1,40) "|" substr($2,1,20) "|" $3 ;}'



相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
10月前
|
SQL Oracle 关系型数据库
Polar DB-O (兼容 Oracle 语法版本)和Polar DB PostgreSQL 版本概述(二)
Polar DB-O (兼容 Oracle 语法版本)和Polar DB PostgreSQL 版本概述(二)
1113 0
|
10月前
|
存储 Oracle 关系型数据库
Polar DB-O (兼容 Oracle 语法版本)和Polar DB PostgreSQL 版本概述(一)
Polar DB-O (兼容 Oracle 语法版本)和Polar DB PostgreSQL 版本概述(一)
466 0
|
12月前
|
存储 NoSQL 关系型数据库
An Overview of PostgreSQL & MySQL Cross Replication
An Overview of PostgreSQL & MySQL Cross Replication
78 0
|
SQL 关系型数据库 API
【PostgreSQL】PostgreSQL扩展:pg_stat_statements 优化SQL
【PostgreSQL】PostgreSQL扩展:pg_stat_statements 优化SQL
|
数据库 索引
PolarDB-X 1.0-SQL 手册-SHOW-SHOW GLOBAL INDEX
PolarDB-X支持使用全局二级索引,本文将介绍如何使用SHOW GLOBAL INDEX命令查看已创建或创建中的全局二级索引。
117 0
|
SQL 前端开发 数据库
PolarDB-X 1.0-SQL 手册-SHOW-SHOW METADATA LOCK
本文将介绍如何在PolarDB-X上使用SHOW METADATA LOCK语句查询持有锁的事务。
116 0
|
SQL 关系型数据库 分布式数据库
PolarDB-X 1.0-SQL 手册-SHOW-SHOW-SHOW HELP
SHOW HELP 展示 DRDS 所有辅助 SQL 指令及其说明。
121 0
|
关系型数据库 API 数据库
PostgreSQL pg_start_backup
本文探讨 pg_start_backup命令的连续归档备份
1465 0
PostgreSQL pg_start_backup
|
数据库 索引 关系型数据库
|
SQL 监控 关系型数据库