Configure Settings Function
Below are functions to query and modify runtime configuration parameters, see the table below.
Function | Returned values | Description | Sample code | Result |
current_setting(setting_name) | text | Current Parameter Value | SELECT current_setting('datestyle'); | current_setting ----------------- ISO, MDY |
set_config(setting_name, new_value, is_local) | text | Set parameter values and return the latest values | SELECT set_config('log_statement_stats', 'off', false); | set_config ------------ off |
Service Signal Function
Function | Returned values | Description |
pg_cancel_backend(pid int) | boolean | Cancel a current backend query |
pg_reload_conf() | boolean | Trigger a configuration file reload |
pg_rotate_logfile() | boolean | Scroll server log files. Useful only for built-in log collectors; others are not useful as they do not manage log subprocesses |
Database Object Size Function
Function | Returned values | Description | Sample code | Result |
pg_column_size(any) | int | Get the storage space in bytes | select pg_column_size('ddewewe'); | 8 |
pg_database_size(oid) | bigint | Specify the database size | select oid,* from pg_database; select pg_database_size(16384); | pg_database_size ------------------ 127632410 |
pg_database_size(name) | bigint | Specify the database size | select pg_database_size('gpperfmon'); | 127632410 |
pg_relation_size(oid) | bigint | Get the size of specified table or index | select pg_relation_size(17787); | pg_relation_size ------------------ 65536 |
pg_relation_size(text) | bigint | Get the size of tables or indexes | select pg_relation_size('t1'); | pg_relation_size ------------------ 65536 |
pg_size_pretty(bigint) | text | Convert the number of bytes to a formatted size | select pg_size_pretty(122212121); | pg_size_pretty ---------------- 117 MB |
pg_tablespace_size(oid) | bigint | Get the size of specified tablespace | select oid,* from pg_tablespace ; select pg_tablespace_size(1663); | pg_tablespace_size -------------------- 262275170 |
pg_tablespace_size(name) | bigint | Get the size of specified tablespace | select pg_tablespace_size('pg_default'); | pg_tablespace_size -------------------- 262275170 |
pg_total_relation_size(oid) | bigint | Disk space occupied by the specified table, including indexes and data | select oid,relname from pg_class where relname='t1'; select pg_total_relation_size(17787); | pg_total_relation_size ------------------------ 65536 (1 row) |
pg_total_relation_size(text) | bigint | Disk space occupied by the specified table, including indexes and data | select pg_total_relation_size('t1'); | pg_total_relation_size ------------------------ 65536 |