云服务器内容精选

  • current_setting(setting_name) 描述:当前的设置值。 返回值类型:text 备注:current_setting用于以查询形式获取setting_name的当前值。和SQL语句SHOW是等效的。比如: 1 2 3 4 5 6 SELECT current_setting('datestyle'); current_setting ----------------- ISO, MDY (1 row)
  • set_config(setting_name, new_value, is_local) 描述:设置参数并返回新值。 返回值类型:text 备注:set_config将参数setting_name设置为new_value,如果is_local为true,则新值将只应用于当前事务。如果希望新值应用于当前会话,可以使用false,和SQL语句SET是等效的。比如: 1 2 3 4 5 6 SELECT set_config('log_statement_stats', 'off', false); set_config ------------ off (1 row)
  • get_tsc_info() 描述:重新获取当前数据库节点的TSC(TimeStamp-Counter)信息。该函数仅8.2.1及以上集群版本支持。 返回值类型:record 表5 返回值字段 名称 类型 描述 node_name text 节点名称。 tsc_mult bigint TSC换算乘数。 tsc_shift bigint TSC换算位移数。 tsc_frequency float8 TSC频率。 tsc_use_freqency boolean 是否使用TSC频率进行时间换算。 tsc_ready boolean 是否可以使用TSC频率进行时间换算。 tsc_scalar_error_info text 获取TSC换算信息的错误信息。 tsc_freq_error_info text 获取TSC频率的错误信息。
  • test_tsc_info(time float8, loops int) 描述:测试当前节点通过TSC(TimeStamp-Counter)换算时间的准确性。该函数仅8.2.1及以上集群版本支持。 输入参数含义如下: time:测试的时间差(单位s),测试时长需要小于或者等于60s loops:测试次数,范围值[1,10] 返回值类型:record 返回值字段: id:循环次数。 real_time_diff:通过gettimeofday获取的时间差(单位us)。 est_time_scalar:通过TSC换算信息转换得到的时间差(单位us)。 est_time_frequency:通过TSC频率转换得到的时间差(单位us)。 示例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 SELECT * FROM test_tsc_info(0.01,10); id | real_time_diff | est_time_scalar | est_time_frequency ----+----------------+-----------------+-------------------- 1 | 10057 | | 10056.9 2 | 10057 | | 10057.4816666667 3 | 10056 | | 10055.2841666667 4 | 10054 | | 10054.4908333333 5 | 10055 | | 10054.2875 6 | 10055 | | 10054.7483333333 7 | 10055 | | 10054.4725 8 | 10054 | | 10054.0766666667 9 | 10058 | | 10058.1016666667 10 | 10057 | | 10056.3733333333 (10 rows)
  • get_all_col_file_vacuum_info(force_get_rewritten_file_num bool) 描述:查询全库所有列存表的文件vacuum相关信息。该函数仅8.2.0.100及以上集群版本支持。 参数:是否强制获取准确的可清理文件数(必选,true或false) 返回值类型:record 返回值字段: node_name:DN节点名。 schema_name:模式名。 table_name:表名。 total_file_num:总CU文件数。 rewritable_file_num:可重写,但还未重写的文件数。 rewritten_file_num:已重写未清理文件数,此值来源于内存态ClearCache,若由于重启等原因ClearCache丢失,可通过设置force_get_rewritten_file_num=true,消耗额外的时间,强制获取准确的可清理文件数。 empty_file_num:已清理文件数。 示例: 1 2 3 4 5 6 7 8 9 SELECT * FROM get_all_col_file_vacuum_info(false); node_name | schema_name | table_name | total_file_num | rewritable_file_num | rewritten_file_num | empty_file_num -----------+-------------+----------------------+----------------+---------------------+--------------------+---------------- datanode1 | public | udi_57373 | 2 | 0 | 0 | 1 datanode1 | public | udi_57374 | 2 | 0 | 0 | 1 datanode2 | public | udi_57373 | 2 | 0 | 0 | 1 datanode2 | public | udi_57374 | 2 | 0 | 0 | 1 datanode3 | public | udi_57373 | 2 | 0 | 0 | 1 datanode3 | public | udi_57374 | 2 | 0 | 0 | 1
  • show_tsc_info() 描述:查询当前数据库节点已获取的TSC(TimeStamp-Counter)信息。该函数仅8.2.1及以上集群版本支持。 返回值类型:record 表4 返回值字段 名称 类型 描述 node_name text 节点名称。 tsc_mult bigint TSC换算乘数。 tsc_shift bigint TSC换算位移数。 tsc_frequency float8 TSC频率。 tsc_use_freqency boolean 是否使用TSC频率进行时间换算。 tsc_ready boolean 是否可以使用TSC频率进行时间换算。 tsc_scalar_error_info text 获取TSC换算信息的错误信息。 tsc_freq_error_info text 获取TSC频率的错误信息。 示例: 1 2 3 4 SELECT * FROM show_tsc_info(); node_name | tsc_mult | tsc_shift | tsc_frequency | tsc_use_frequency | tsc_ready | tsc_scalar_error_info | tsc_freq_error_info --------------+----------+-----------+---------------+-------------------+-----------+-------------------------------+--------------------- coordinator1 | | | 2400 | t | t | TSC scalar is not initialized |
  • get_all_col_cu_info(row_count int8) 描述:查询全库所有列存表的CU信息。该函数仅8.2.0.100及以上集群版本支持。 参数:小CU的行数阈值(可选,默认值200,取值范围为1~60000。) 返回值类型:record 返回值字段: node_name:DN节点名。 schema_name:模式名。 table_name:表名。 zero_size_cu_count:cuSize=0,且行数小于等于row_count的CU数。 small_cu_count:cuSize=ALIGNOF_CUSIZE(8192),且行数小于等于row_count的CU数。 total_cu_count:总CU数。 small_cu_size:8kCU的总大小。 total_cu_size:总CU大小。 示例: 1 2 3 4 5 6 7 8 9 10 SELECT * FROM get_all_col_cu_info(200); node_name | schema_name | table_name | zero_size_cu_count | small_cu_count | total_cu_count | small_cu_size | total_cu_size -----------+-------------+----------------------+--------------------+----------------+----------------+---------------+--------------- datanode1 | public | udi_48076 | 5 | 1 | 6 | 8192 bytes | 8192 bytes datanode1 | public | udi_48077 | 5 | 1 | 6 | 8192 bytes | 8192 bytes datanode2 | public | udi_48076 | 5 | 1 | 6 | 8192 bytes | 8192 bytes datanode2 | public | udi_48077 | 5 | 1 | 6 | 8192 bytes | 8192 bytes datanode3 | public | udi_48076 | 5 | 1 | 6 | 8192 bytes | 8192 bytes datanode3 | public | udi_48077 | 5 | 1 | 6 | 8192 bytes | 8192 bytes (6 rows)
  • get_col_file_vacuum_info(schema_name text, table_name text, colvacuum_threshold_scale_factor int) 描述:查询某张列存表的文件vacuum相关信息,每个分区单独统计。该函数仅8.2.0.100及以上集群版本支持。 参数:模式名(必选),表名(必选),colvacuum_threshold_scale_factor(必选,0-100为dead tuple的比例值) 返回值类型:record 返回值: node_name:DN节点名。 part_name:分区名,普通表此列为空。 total_file_num:总CU文件数。 rewritable_file_num:可重写,但还未重写的文件数。 rewritten_file_num:已重写未清理文件数,此值来源于内存态ClearCache,若由于重启等原因ClearCache丢失,可通过设置force_get_rewritten_file_num=true,消耗额外的时间,强制获取准确的可清理文件数。 empty_file_num:已清理文件数。 示例: 1 2 3 4 5 6 7 8 9 10 SELECT * FROM get_col_file_vacuum_info('public','pa',10); node_name | part_name | total_file_num | rewritable_file_num | rewritten_file_num | empty_file_num -----------+-----------+----------------+---------------------+--------------------+---------------- datanode1 | pa1 | 1 | 0 | 0 | 0 datanode1 | pa2 | 1 | 0 | 0 | 0 datanode2 | pa1 | 1 | 0 | 0 | 0 datanode2 | pa2 | 1 | 0 | 0 | 0 datanode3 | pa1 | 1 | 0 | 0 | 0 datanode3 | pa2 | 1 | 0 | 0 | 0 (6 rows)
  • get_col_file_vacuum_info(schema_name text, table_name text, force_get_rewritten_file_num bool) 描述:查询某张列存表的文件vacuum相关信息,每个分区单独统计。该函数仅8.2.0.100及以上集群版本支持。 参数:模式名(必选),表名(必选),是否强制获取准确的可清理文件数(必选,默认为false) 返回值类型:record 返回值字段: node_name:DN节点名。 part_name:分区名,普通表此列为空。 total_file_num:总CU文件数。 rewritable_file_num:可重写,但还未重写的文件数。 rewritten_file_num:已重写未清理文件数,此值来源于内存态ClearCache,若由于重启等原因ClearCache丢失,可通过设置force_get_rewritten_file_num=true,消耗额外的时间,强制获取准确的可清理文件数。 empty_file_num:已清理文件数。 示例: 1 2 3 4 5 6 7 8 9 10 SELECT * FROM get_col_file_vacuum_info('public','pa',false); node_name | part_name | total_file_num | rewritable_file_num | rewritten_file_num | empty_file_num -----------+-----------+----------------+---------------------+--------------------+---------------- datanode1 | pa1 | 1 | 0 | 0 | 0 datanode1 | pa2 | 1 | 0 | 0 | 0 datanode2 | pa1 | 1 | 0 | 0 | 0 datanode2 | pa2 | 1 | 0 | 0 | 0 datanode3 | pa1 | 1 | 0 | 0 | 0 datanode3 | pa2 | 1 | 0 | 0 | 0 (6 rows)
  • get_volatile_pg_attribute(relname text, attrname text) 描述:获取当前会话中指定volatile临时表相关的pg_attribute元数据。该函数仅8.2.0及以上集群版本支持。 参数: relname:表名(必须在当前会话中)。 attrname:列名。 返回值类型:record 返回值字段: oid:返回该列信息的oid。 其他字段:同pg_attribute系统表中的基础字段(不包括系统隐藏字段)。 示例: 1 2 3 4 5 6 7 8 SELECT * FROM get_volatile_pg_attribute('tx1', 'b'); attrelid | attname | atttypid | attstattarget | attlen | attnum | attndims | attcacheoff | atttypmod | attbyval | attstorage | attalign | attnotnull | atthasdef | attisdropped | attislocal | attcmprmode | attinhcount | attcollation | attacl | attoptions | attfdwoptions | attinitdefval | attkvtype ----------+---------+----------+---------------+--------+--------+----------+-------------+-----------+----------+------------+----------+------------+-----------+--------------+------------+ -------------+-------------+--------------+--------+------------+---------------+---------------+----------- 16772 | b | 25 | -1 | -1 | 2 | 0 | -1 | -1 | f | x | i | f | f | f | t | 127 | 0 | 100 | | | | | 0 (1 row)
  • pg_get_publication_tables(pubname text) 描述:根据发布的名称,返回对应发布要发布的表的relid列表。该函数仅8.2.0.100及以上集群版本支持。 参数:pubname 返回值类型:set of oid 示例: 1 2 3 4 5 6 SELECT * FROM pg_get_publication_tables('mypub'); relid ------- 16757 16776 (2 rows)
  • pg_relation_is_publishable(relname regclass) 描述:检查一个表是否可以发布。该函数仅8.2.0.100及以上集群版本支持。 参数:relname 返回值类型:boolean 示例: 1 2 3 4 5 SELECT * FROM pg_relation_is_publishable('t1'); pg_relation_is_publishable ---------------------------- t (1 row)
  • get_col_cu_info(schema_name text, table_name text, row_count int8, dirty_percent int8) 描述:查询某张列存表的CU信息,每个分区单独统计。该函数仅8.2.0.100及以上集群版本支持。 参数:模式名(必选),表名(必选),小CU的行数阈值(可选,默认200,取值范围为1~60000),脏CU的删除百分比阈值(可选,默认70,取值范围1~100)。 返回值类型:record 返回值字段: node_name:DN节点名。 part_name:分区名,普通表此列为空。 zero_size_cu_count:cuSize=0,且行数小于等于row_count的CU数。 small_cu_count:cuSize=ALIGNOF_CUSIZE(8192),且行数小于等于row_count的CU数。 dirty_cu_count: 因delete,deadtupe占比超过dirty_percent的CU数。 total_cu_count:总CU数。 small_cu_size:8k CU的总大小。 total_cu_size:总CU大小。 示例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 SELECT * FROM get_col_cu_info('public','hs_part'); node_name | part_name | zero_size_cu_count | small_cu_count | dirty_cu_count | total_cu_count | small_cu_size | total_cu_size -----------+-----------+--------------------+----------------+----------------+----------------+---------------+--------------- dn_1 | p1 | 3 | 0 | 0 | 3 | 0 bytes | 0 bytes dn_1 | p2 | 3 | 0 | 0 | 3 | 0 bytes | 0 bytes dn_1 | p3 | 3 | 0 | 0 | 3 | 0 bytes | 0 bytes (3 rows) SELECT * FROM get_col_cu_info('public','hs_part', 200, 90); node_name | part_name | zero_size_cu_count | small_cu_count | dirty_cu_count | total_cu_count | small_cu_size | total_cu_size -----------+-----------+--------------------+----------------+----------------+----------------+---------------+--------------- dn_1 | p1 | 3 | 0 | 0 | 3 | 0 bytes | 0 bytes dn_1 | p2 | 3 | 0 | 0 | 3 | 0 bytes | 0 bytes dn_1 | p3 | 3 | 0 | 0 | 3 | 0 bytes | 0 bytes (3 rows)
  • get_volatile_pg_class(relname text) 描述:获取当前会话中指定volatile临时表相关的pg_class元数据。该函数仅8.2.0及以上集群版本支持。 参数:当前会话中volatile临时表表名。 返回值类型:record 返回值字段: oid:返回volatile临时表的oid。 其他字段:同pg_class系统表中的基础字段(不包括系统隐藏字段)。 示例: 1 2 3 4 5 6 7 8 9 10 11 SELECT * FROM get_volatile_pg_class('tx1'); oid | relname | relnamespace | reltype | reloftype | relowner | relam | relfilenode | reltablespace | relpages | reltuples | relallvisible | reltoastrelid | reltoastidxid | reldeltarelid | reldeltaidx | relcudescrelid | relcudescidx | relhasindex | relisshared | relpersistence | relkind | relnatts | relchecks | relhasoids | relhaspkey | relhasrules | relhastriggers | relhassub class | relcmprs | relhasclusterkey | relrowmovement | parttype | relfrozenxid | relacl | reloptions | relreplident | relfrozenxid64 -------+---------+--------------+---------+-----------+----------+-------+-------------+---------------+----------+-----------+---------------+---------------+---------------+---------------+ -------------+----------------+--------------+-------------+-------------+----------------+---------+----------+-----------+------------+------------+-------------+----------------+---------- ------+----------+------------------+----------------+----------+--------------+--------+----------------------------------+--------------+---------------- 16772 | tx1 | 16770 | 16774 | 0 | 10 | 0 | 16772 | 1665 | 0 | 0 | 0 | 16775 | 0 | 0 | 0 | 0 | 0 | f | f | v | r | 2 | 0 | f | f | f | f | f | 1 | f | f | n | 11815 | | {orientation=row,compression=no} | d | 11815 (1 row)
  • create_wdr_snapshot() 描述:创建性能数据快照。 返回值类型:text 该函数只有数据库管理员SYSADMIN才可以执行,非管理员执行会提示无权限。 该函数只能在CN上执行,在DN上执行会返回:“WDR snapshot can only be created on coordinator.”。 执行该函数前需确认enable_wdr_snapshot参数处于开启状态。如果enable_wdr_snapshot为off,执行该函数会返回:“WDR snapshot request can't be executed, because GUC parameter 'enable_wdr_snapshot' is off.”。 如果执行该函数时,快照线程由于节点重启等原因尚未启动,会提示错误:“WDR snapshot request can not be accepted, please retry later.”。 如果执行该函数失败,会提示:“Cannot respond to WDR snapshot request.”。 如果执行成功,会返回:“WDR snapshot request has been submitted.”。该提示表明创建快照请求已发送至后台快照线程,但不代表创建快照成功。