Updated on 2025-05-29 GMT+08:00

Multi-Tenant Database Functions

gs_reload_pdb_conf(name pdbname)

Description: Makes the configuration file of a specified PDB take effect immediately. Only the local PDB can be specified in a PDB. The input parameter can be empty. If the input parameter is left empty, the configuration file of the PDB can be called only in the PDB and takes effect.

Return type: Boolean

Note: Each of these functions returns true if they are successful and false otherwise. Only users with the SYSADMIN permission or higher can execute this function.

gs_resplan_cgroup_info()

Description: Returns the architecture and quota details of a multi-tenant Cgroup. Its function is the same as that of gs_cgroup -p. All data can be viewed in a CDB. Only the data within the PDB range can be viewed in a PDB. It returns a CGroup (such as DefaultClass, DefaultBackend, and Vacuum) of a CGroup framework and the Class_xxx Cgroup of a PDB on the primary node. An error is reported when the function is executed on the standby node.

Return type: SETOF record

Name

Type

Description

cgroup_name

text

Cgroup name.

shares

bigint

CPU quota allocated to the Cgroup.

quota

bigint

Maximum number of CPU resources that can be used by the Cgroup.

cpuset

text

Allocated CPU cores.

cpu_usage

real

Total CPU usage time of the Cgroup.

relpath

text

Relative path of the Cgroup.

task_num

bigint

Number of threads in the Cgroup.

group_id

bigint

Thread group ID.

is_disable

boolean

Specifies whether the Cgroup is unavailable.

Example:

1
2
3
4
5
6
7
8
gaussdb=# select * FROM GS_RESPLAN_CGROUP_INFO();
      cgroup_name       | shares | quota | cpuset | cpu_usage |            relpath             | task_num | group_id | is_disable
------------------------+--------+-------+--------+-----------+--------------------------------+----------+----------+------------
 Default_Class          |   2048 |    -1 | 0-15   |         0 | CDB:omm/Default_Class          |       17 |        0 | f
 Backend                |  12288 |    -1 | 0-15   |   4.90895 | CDB:omm/Backend                |        0 |        0 | f
 Backend/DefaultBackend |  81920 |    -1 | 0-15   |   4.91018 | CDB:omm/Backend/DefaultBackend |       44 |        0 | f
 Backend/Vacuum         |  20480 |    -1 | 0-15   |         0 | CDB:omm/Backend/Vacuum         |        0 |        0 | f
(4 rows)

gs_resplan_stat_info(view_type integer)

Description: Returns the real-time statistics result of the resource plan in the current CDB, including the CPU, memory, and I/O indicators. You can obtain real-time data, statistics of the last minute, and historical statistics of each minute (up to one hour).

All data can be viewed in a CDB. Only the data within the PDB range can be viewed in a PDB. An error is reported when the function is executed on the standby node.

When resources change, the shared cache counted by used_shared_memory starts from 0. As services are running, the value of used_shared_memory increases, and the statistics become normal. During this period, the performance is not affected.

The following lists the input parameters.

Name

Type

Input/Output

Value Range

Description

view_type

integer

Input

[0,1,2]

0: Real-time statistics are returned.

1: The latest statistics are returned.

2: Historical statistics of the last hour are returned.

Return type: SETOF record

Name

Type

Description

plan_name

text

Name of the resource plan that is taking effect at end_time.

pdb_name

name

For a CDB, the value is cdb. For a PDB, the value is the PDB name.

begin_time

timestamp with time zone

Collection start time. During real-time statistics collection, no value is returned.

end_time

timestamp with time zone

Collection end time. During real-time statistics collection, now is returned.

interval_msec

integer

Interval for collecting statistics, in milliseconds (ms).

cpu_consumed_time

bigint

CPU usage time in the current period, in milliseconds (ms). The usage time of multiple cores is accumulated.

avg_cpu_utilization

double precision

CPU usage. The formula is as follows: cpu_consumed_time/interval_msec/Number of CPU cores of CDB.

iops

double precision

IOPS in this period. During real-time statistics collection, the IOPS of the last second is returned. During periodic statistics collection, the IOPS of the period is returned.

used_dynamic_memory

integer

Dynamic memory used at end_time, in KB.

used_shared_memory

integer

Shared cache used at end_time, in KB.

used_connections

integer

Number of connections used at the current time.

logical_decoder_used_memory

integer

Dynamic memory used by a logical decoding task at end_time, in KB.

Example:

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
gaussdb=# SELECT * FROM gs_resplan_stat_info(0);
       plan_name       | pdb_name | begin_time |           end_time           | interval_msec | cpu_consumed_time | avg_cpu_utilization | iops | used_dynamic_memory | used_shared_memory | used_connections | logical_decoder_used_memory 
-----------------------+----------+------------+------------------------------+---------------+-------------------+---------------------+------+---------------------+--------------------+------------------+-----------------------------
 default_resource_plan | cdb      |            | 2024-11-11 18:03:05.37086+08 |               |             50632 |                     |    0 |                8192 |               7368 |                1 |                           0
(1 row)

gaussdb=# SELECT * FROM gs_resplan_stat_info(1);
       plan_name       | pdb_name |          begin_time           |           end_time            | interval_msec | cpu_consumed_time | avg_cpu_utilization | iops | used_dynamic_memory | used_shared_memory | used_connections | logical_d
ecoder_used_memory 
-----------------------+----------+-------------------------------+-------------------------------+---------------+-------------------+---------------------+------+---------------------+--------------------+------------------+----------
-------------------
 default_resource_plan | cdb      | 2024-11-11 18:02:50.335556+08 | 2024-11-11 18:03:00.339938+08 |         10005 |               421 |    .262993503248376 |    0 |                7168 |               7368 |                1 |          
                 0
(1 row)

gaussdb=# SELECT * FROM gs_resplan_stat_info(2);
       plan_name       | pdb_name |          begin_time           |           end_time            | interval_msec | cpu_consumed_time | avg_cpu_utilization | iops | used_dynamic_memory | used_shared_memory | used_connections | logical_d
ecoder_used_memory 
-----------------------+----------+-------------------------------+-------------------------------+---------------+-------------------+---------------------+------+---------------------+--------------------+------------------+----------
-------------------
 default_resource_plan | cdb      | 2024-11-11 17:53:00.138608+08 | 2024-11-11 17:53:10.141111+08 |         10003 |               428 |     .26741977406778 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:53:10.141111+08 | 2024-11-11 17:53:20.144848+08 |         10004 |               448 |    .279888044782087 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:53:20.144848+08 | 2024-11-11 17:53:30.147538+08 |         10003 |               519 |    .324277716684994 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:53:30.147538+08 | 2024-11-11 17:53:40.150645+08 |         10004 |               435 |    .271766293482607 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:53:40.150645+08 | 2024-11-11 17:53:50.152916+08 |         10003 |               458 |    .286164150754774 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:53:50.152916+08 | 2024-11-11 17:54:00.155912+08 |         10003 |               420 |    .262421273617915 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:54:00.155912+08 | 2024-11-11 17:54:10.159175+08 |         10004 |               419 |    .261770291883247 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:54:10.159175+08 | 2024-11-11 17:54:20.16135+08  |         10003 |               458 |    .286164150754774 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:54:20.16135+08  | 2024-11-11 17:54:30.163531+08 |         10003 |               520 |    .324902529241228 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:54:30.163531+08 | 2024-11-11 17:54:40.165763+08 |         10003 |               563 |    .351769469159252 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:54:40.165763+08 | 2024-11-11 17:54:50.168769+08 |         10004 |               421 |    .263019792083167 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:54:50.168769+08 | 2024-11-11 17:55:00.171637+08 |         10003 |               458 |    .286164150754774 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:55:00.171637+08 | 2024-11-11 17:55:10.174908+08 |         10004 |               425 |    .265518792483007 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:55:10.174908+08 | 2024-11-11 17:55:20.179252+08 |         10005 |               428 |    .267366316841579 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:55:20.179252+08 | 2024-11-11 17:55:30.183558+08 |         10005 |               545 |    .340454772613693 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:55:30.183558+08 | 2024-11-11 17:55:40.18557+08  |         10003 |               436 |    .272418274517645 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:55:40.18557+08  | 2024-11-11 17:55:50.189828+08 |         10005 |               412 |    .257371314342829 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:55:50.189828+08 | 2024-11-11 17:56:00.193059+08 |         10004 |               432 |    .269892043182727 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:56:00.193059+08 | 2024-11-11 17:56:10.195868+08 |         10003 |               504 |    .314905528341498 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:56:10.195868+08 | 2024-11-11 17:56:20.199766+08 |         10004 |               434 |    .271141543382647 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:56:20.199766+08 | 2024-11-11 17:56:30.203198+08 |         10004 |               514 |    .321121551379448 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:56:30.203198+08 | 2024-11-11 17:56:40.205889+08 |         10003 |               486 |    .303658902329301 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:56:40.205889+08 | 2024-11-11 17:56:50.207217+08 |         10002 |               425 |    .265571885622875 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:56:50.207217+08 | 2024-11-11 17:57:00.210596+08 |         10004 |               417 |    .260520791683327 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:57:00.210596+08 | 2024-11-11 17:57:10.215004+08 |         10005 |               446 |    .278610694652674 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:57:10.215004+08 | 2024-11-11 17:57:20.219176+08 |         10005 |               418 |     .26111944027986 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:57:20.219176+08 | 2024-11-11 17:57:30.222697+08 |         10004 |               499 |    .311750299880048 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:57:30.222697+08 | 2024-11-11 17:57:40.226854+08 |         10005 |               439 |     .27423788105947 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:57:40.226854+08 | 2024-11-11 17:57:50.2311+08   |         10005 |               452 |    .282358820589705 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:57:50.2311+08   | 2024-11-11 17:58:00.235139+08 |         10005 |               417 |    .260494752623688 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:58:00.235139+08 | 2024-11-11 17:58:10.235896+08 |         10001 |               424 |    .264973502649735 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:58:10.235896+08 | 2024-11-11 17:58:20.239277+08 |         10004 |               458 |    .286135545781687 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:58:20.239277+08 | 2024-11-11 17:58:30.242792+08 |         10004 |               510 |    .318622550979608 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:58:30.242792+08 | 2024-11-11 17:58:40.246556+08 |         10004 |               434 |    .271141543382647 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:58:40.246556+08 | 2024-11-11 17:58:50.249977+08 |         10004 |               449 |    .280512794882047 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:58:50.249977+08 | 2024-11-11 17:59:00.253508+08 |         10004 |               430 |    .268642542982807 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:59:00.253508+08 | 2024-11-11 17:59:10.257666+08 |         10005 |               415 |    .259245377311344 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:59:10.257666+08 | 2024-11-11 17:59:20.261004+08 |         10004 |               424 |    .264894042383047 |    0 |                5120 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:59:20.261004+08 | 2024-11-11 17:59:30.265189+08 |         10005 |              1267 |    .791479260369815 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:59:30.265189+08 | 2024-11-11 17:59:40.26769+08  |         10003 |              2676 |    1.67199840047986 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:59:40.26769+08  | 2024-11-11 17:59:50.270465+08 |         10003 |               441 |     .27554233729881 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 17:59:50.270465+08 | 2024-11-11 18:00:00.274369+08 |         10004 |               469 |    .293007796881248 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:00:00.274369+08 | 2024-11-11 18:00:10.277781+08 |         10004 |               437 |    .273015793682527 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:00:10.277781+08 | 2024-11-11 18:00:20.28173+08  |         10004 |               432 |    .269892043182727 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:00:20.28173+08  | 2024-11-11 18:00:30.286008+08 |         10005 |               521 |    .325462268865567 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:00:30.286008+08 | 2024-11-11 18:00:40.287632+08 |         10002 |               465 |    .290566886622675 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:00:40.287632+08 | 2024-11-11 18:00:50.292495+08 |         10005 |               409 |    .255497251374313 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:00:50.292495+08 | 2024-11-11 18:01:00.294311+08 |         10002 |               419 |    .261822635472905 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:01:00.294311+08 | 2024-11-11 18:01:10.298553+08 |         10005 |               467 |    .291729135432284 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:01:10.298553+08 | 2024-11-11 18:01:20.301856+08 |         10004 |               434 |    .271141543382647 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:01:20.301856+08 | 2024-11-11 18:01:30.306115+08 |         10005 |               531 |    .331709145427286 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:01:30.306115+08 | 2024-11-11 18:01:40.3094+08   |         10004 |               478 |    .298630547780888 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:01:40.3094+08   | 2024-11-11 18:01:50.313554+08 |         10005 |               422 |    .263618190904548 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:01:50.313554+08 | 2024-11-11 18:02:00.316731+08 |         10004 |               415 |    .259271291483407 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:02:00.316731+08 | 2024-11-11 18:02:10.320966+08 |         10005 |               414 |    .258620689655172 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:02:10.320966+08 | 2024-11-11 18:02:20.325226+08 |         10005 |               449 |    .280484757621189 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:02:20.325226+08 | 2024-11-11 18:02:30.328873+08 |         10004 |               503 |    .314249300279888 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:02:30.328873+08 | 2024-11-11 18:02:40.332684+08 |         10004 |               445 |    .278013794482207 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:02:40.332684+08 | 2024-11-11 18:02:50.335556+08 |         10003 |               479 |    .299285214435669 |    0 |                7168 |               7368 |                1 |          
                 0
 default_resource_plan | cdb      | 2024-11-11 18:02:50.335556+08 | 2024-11-11 18:03:00.339938+08 |         10005 |               421 |    .262993503248376 |    0 |                7168 |               7368 |                1 |          
                 0
(60 rows)

gs_get_pdb_tablespace_location(pdb_id oid in, tablespace_oid oid in)

Description: Returns the tablespace path according to the given PDB ID and tablespace OID.

The following lists the input parameters.

Name

Type

Input/Output

Value Range

Description

pdb_id

oid

Input

[1, 4095]

PDB ID.

tablespace_oid

oid

Input

[0, 4294967295]

Tablespace OID.

Return type: text

Currently, you are advised not to use this function. It is used only for kernel function implementation. If the input parameter pdb_id is not in the range, NULL is returned. If the input parameter pdb_id is PDB ID of another PDB, an empty string is returned. If the running user is not superuser or sysdba, an empty string is returned. If the queried PDB does not have the corresponding tablespace, an error is reported.

get_mtd_user()

Description: Displays all user information by DB and user. In the multi-tenancy scenario, global information is returned if this function is called in a non-PDB, and information about a PDB is returned if this function is called in the PDB.

Return type: SETOF record

Name

Type

Description

dbid

oid

Database ID.

usename

name

Username.

usesysid

oid

User ID.

usecreatedb

boolean

Specifies whether a user has the permissions to create databases.

  • t (true): yes.
  • f (false): no.

usesuper

boolean

Specifies whether the user is the initial system administrator with the highest permissions.

  • t (true): yes.
  • f (false): no.

usecatupd

boolean

Specifies whether the user can directly update system catalogs. Only the initial system administrator whose usesysid is 10 has this permission. This permission is unavailable for other users.

  • t (true): yes.
  • f (false): no.

userepl

boolean

Specifies whether the user has the permissions to duplicate data streams.

  • t (true): yes.
  • f (false): no.

passwd

text

Encrypted user password. The value is displayed as ********.

valbegin

timestamp with time zone

Start time for account validity (NULL if no start time).

valuntil

timestamp with time zone

End time for account validity (NULL if no end time).

respool

name

Resource pool where the user is located.

parent

oid

Parent user OID.

spacelimit

text

Storage space of a permanent table, in KB.

useconfig

text

Default value of GUC items. For details, see section "PG_DB_ROLE_SETTING.setconfig."

nodegroup

name

Name of a logical database associated with a user. If the user does not manage the logical database, this column is left blank.

tempspacelimit

text

Storage space of a temporary table, in KB.

spillspacelimit

text

Operator disk spill space, in KB.

usemonitoradmin

boolean

Specifies whether this user is a MONADMIN.

  • t (true): yes.
  • f (false): no.

useoperatoradmin

boolean

Specifies whether the user is an OPRADMIN.

  • t (true): yes.
  • f (false): no.

usepolicyadmin

boolean

Specifies whether the user is a POLADMIN.

  • t (true): yes.
  • f (false): no.

get_instr_sql_count_info()

Description: Provides the count of SELECT, UPDATE, INSERT, DELETE, and MERGE INTO statements executed by the user on the current node by DB and user. In the multi-tenancy scenario, the global information is returned if this function is called in a non-PDB, and only the information about a local PDB is returned if this function is called in a PDB.

Return type: record

get_instr_db_rt_percentile()

Description: Displays the distribution information about the response time of 80% and 95% SQL statements by DB. Only the distribution information about the response time of 80% and 95% SQL statements of the current PDB is returned if this function is executed in the PDB.

Return type: record

Example:

-- Query in a CDB.
gaussdb=# select * from get_instr_db_rt_percentile();
    DBID    | P80  | P95
------------+------+------
      14539 | 7375 | 7547
 1255163054 | 3909 | 6558
(2 rows)

-- Query in a PDB.
gaussdb=# \c pdb1
pdb1=# select * from get_instr_db_rt_percentile();
    DBID    | P80  | P95
------------+------+------
 1255163054 | 6220 | 7358
(1 row)

get_instr_user_login_info()

Description: Displays the number of user logins and logouts on the current node by DB and user. To query this function, you must have the SYSADMIN or MONADMIN permission. If this function is executed in the PDB, only the login and logout information of the current PDB is returned.

Return type: record

Example:

-- Query in a CDB.
gaussdb=#  select * from get_instr_user_login_info();
 node_name |    dbid    | user_id | login_counter | logout_counter
-----------+------------+---------+---------------+----------------
 datanode  |      14539 |      10 |         82183 |          82182
 datanode  | 1255163054 |      10 |         39932 |          39932
(2 rows)

-- Query in a PDB.
gaussdb=# \c pdb1
pdb1=#  select * from get_instr_user_login_info();
 node_name |    dbid    | user_id | login_counter | logout_counter
-----------+------------+---------+---------------+----------------
 datanode  | 1255163054 |      10 |         39933 |          39932
(1 row)

gs_resplan_shared_memory_info()

Description: Displays detailed information about the shared cache of all available resource pools. This system function takes effect only when the GUC parameter enable_mtd is set to on and can be viewed only by system administrators in the CDB of the host.

Return type: SETOF record

Name

Type

Description

respool_oid

oid

OID of the resource pool.

allocated_shared_memory

bigint

Size of the shared memory that has been allocated, in KB.

respool_group_shared_memory

bigint

Size of the memory occupied by each resource pool in the shared memory, in KB.

avaliable_shared_memory

bigint

Size of the available shared memory of each resource pool, in KB.

real_used_shared_memory

bigint

Size of the shared memory used by each resource pool, in KB.

shared_memory_hits_per

bigint

Hit ratio of the buffer found in the shared memory.

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
gaussdb=# select * from gs_resplan_shared_memory_info();
 respool_oid | allocated_shared_memory | respool_group_shared_memory | avaliable_shared_memory | real_used_shared_memory | shared_memory_hits_per
-------------+-------------------------+-----------------------------+-------------------------+-------------------------+------------------------
          10 |                    8640 |                        8640 |                 1048568 |                      -1 |                    100
(1 row)

-- After pdb1 is created, join query gs_pdb and gs_resplan_shared_memory_info to obtain information about the PDB resource pool.
gaussdb=# select b.name,a.* from gs_resplan_shared_memory_info() as a LEFT JOIN gs_pdb as b on a.respool_oid=b.grp_respool_oid where name = 'pdb1';
 name | respool_oid | allocated_shared_memory | respool_group_shared_memory | avaliable_shared_memory | real_used_shared_memory | shared_memory_hits_per 
------+-------------+-------------------------+-----------------------------+-------------------------+-------------------------+------------------------
 pdb1 |      155648 |                 1048576 |                     1048576 |                  459400 |                  589176 |                    100
(1 row)