全局临时表函数
-
描述:显示当前会话指定的全局临时表的基本信息。
参数:全局临时表的OID。
返回值类型:record
示例:
1、创建全局临时表并插入数据。
CREATE GLOBAL TEMPORARY TABLE emp( depname varchar, empno bigint, salary int, enroll_date date ); INSERT INTO emp VALUES ('develop', 10, 5200, '2007-08-01'), ('sales', 1, 5000, '2006-10-01'), ('personnel', 5, 3500, '2007-12-10'), ('sales', 4, 4800, '2007-08-08'), ('personnel', 2, 3900, '2006-12-23'), ('develop', 7, 4200, '2008-01-01'), ('develop', 9, 4500, '2008-01-01'), ('sales', 3, 4800, '2007-08-01'), ('develop', 8, 6000, '2006-10-01'), ('develop', 11, 5200, '2007-08-15');
2、查看该全局临时表的oid。
select oid from pg_class where relname='emp';
返回结果如下:
oid ------- 19111 (1 row)
3、调用pg_get_gtt_relstats函数,显示当前会话指定的全局临时表的基本信息。
select * from pg_get_gtt_relstats(19111);
返回结果如下:
relfilenode | relpages | reltuples | relallvisible | relfrozenxid | relminmxid ------------+----------+-----------+---------------+--------------+------------ 19111 | 0 | 0 | 0 | 16567 | 0 (1 row)
pg_get_gtt_statistics(relOid, attnum, ' '::text)
描述:显示当前会话指定的全局临时表的单列统计信息。
参数:全局临时表的OID和属性attnum。
返回值类型:record
示例:
select * from pg_get_gtt_statistics(74069,1,''::text);
返回结果为:
starelid | starelkind | staattnum | stainherit | stanullfrac | stawidth | stadistinct | stakind1 | stakind2 | stakind3 | stakind4 | stakind5 | staop1 | staop2 | staop3 | staop4 | staop5 | stanumbers1 | stanumbers2 | stanumbers3 | stanu mbers4 | stanumbers5 | stavalues1 | stavalues2 | stavalues3 | stavalues4 | stavalues5 | stadndistinct | staextinfo ----------+------------+-----------+------------+-------------+----------+-------------+----------+----------+----------+----------+----------+--------+--------+--------+--------+--------+-------------+-------------+-------------+------ -------+-------------+---------------------------------------------------------------------- -------------------------------------------------------------------------------------------- ------------------------------------------------------------------------+------------+------------+------------+------------+---------------+------------ 74069 | c | 1 | f | 0 | 4 | -1 | 2 | 3 | 0 | 0 | 0 | 97 | 97 | 0 | 0 | 0 | | {1} | | | | {1,130,260,390,520,650,780,910,1040,1170,1300,1430,1560,1690,1820,1950,2080,2210,2340,2470,2600,2730,2860,2990,3120,3250,3380,3510,3640,3770,3900,4030,4160,4290,4420,4550,4680,4810,4940,5070,5200,5330,5460,5590,57 20,5850,5980,6110,6240,6370,6500,6630,6760,6890,7020,7150,7280,7410,7540,7670,7800,7930,8060,8190,8320,8450,8580,8710,8840,8970,9100,9230,9360,9490,9620,9750,9880,10010,10140,10270,10400,10530,10660,10790,10920,11050,11180,11310,11440,1 1570,11700,11830,11960,12090,12220,12350,12480,12610,12740,12870,13000} | | | | | 0 | (1 row)
pg_gtt_attached_pid(relOid)
描述:显示正在使用指定全局临时表的所有线程pid。
参数:全局临时表的OID。
返回值类型:record
示例:
select * from pg_gtt_attached_pid(74069);
返回结果为:
relid | pid ------+----------------- 74069 | 139648170456832 74069 | 139648123270912 (2 rows)
dbe_perf.get_global_full_sql_by_timestamp(start_timestamp timestamp, end_timestamp timestamp)
描述:获取实例级的全量SQL(Full SQL)信息。
返回值类型:record
表 1 dbe_perf.get_global_full_sql_by_timestamp参数说明
dbe_perf.get_global_slow_sql_by_timestamp(start_timestamp timestamp, end_timestamp timestamp)
描述:获取实例级的慢SQL(Slow SQL)信息。
返回值类型:record
表 2 dbe_perf.get_global_slow_sql_by_timestamp参数说明
statement_detail_decode(detail text, format text, pretty bool)
解析全量/慢SQL语句中的details字段的信息。
表 3 statement_detail_decode参数说明
pg_list_gtt_relfrozenxids()
描述:显示各会话的冻结事务xid。
pid=0的行,显示所有会话中最老的冻结事务xid。
参数:无。
返回值类型:record
示例:
select * from pg_list_gtt_relfrozenxids();
返回结果为:
pid | relfrozenxid -----------------+-------------- 139648123270912 | 11151 139648170456832 | 11155 0 | 11151 (3 rows)