plan management管理函数
plan management模块相关函数介绍。
pgxc_bind_plan(sql_hash text, outline_name text, apply_skew_hint boolean DEFAULT false)
描述:为sql_hash对应的语句绑定outline_name对应的outline,即把SQL_OUTLINE系统表中主键outline_name和sql_hash对应的outline绑定给sql_hash对应的语句。第三个参数apply_skew_hint表示是否应用outline中的skew hint,默认为false,即不应用outline中的skew hint。该函数需要数据库管理员用户,或授予了gs_role_sql_management角色权限的用户才能执行。
返回值类型:boolean
示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
SELECT pgxc_bind_plan(sql_hash, outline_name) FROM outlines limit 1; pgxc_bind_plan ---------------- t (1 row) SELECT pgxc_bind_plan('sql_be2995e824abb8b712b69fca4825b532', 'outline_e5214c8e3901da4d7d34166cb9cb84ee'); pgxc_bind_plan ---------------- t (1 row) SELECT pgxc_bind_plan(sql_hash, outline_name, true) FROM outlines WHERE outline ILIKE '%skew%' limit 1; pgxc_bind_plan ---------------- t (1 row) |
pgxc_unbind_plan(sql_hash text)
描述:为sql_hash对应的语句解除绑定的outline。需要数据库管理员用户,或授予了gs_role_sql_management角色权限的用户才能执行。
返回值类型:boolean
示例:
1 2 3 4 5 6 7 8 9 10 11 |
SELECT pgxc_unbind_plan(sql_hash) FROM sql_plan_baseline; pgxc_unbind_plan ------------------ t (1 row) SELECT pgxc_unbind_plan('sql_be2995e824abb8b712b69fca4825b532'); pgxc_unbind_plan ------------------ t (1 row) |
drop_outline(sql_hash text, outline_name text)
描述:从dbms_om.sql_outline系统表中删除指定的outline。只有未被绑定outline才可以删除,且只能由数据库管理员用户,或授予了gs_role_sql_management角色权限的用户才可以删除。
返回值类型:boolean
示例:
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 |
SELECT drop_outline(sql_hash, outline_name) FROM outlines; WARNING: The outline(specified by sql_hash[sql_3d937542c0d24c9c995f31cba327fa56] and outline_name[outline_413ac0e566ff20be320f5ef0774bf1eb]) is bind CONTEXT: referenced column: drop_outline drop_outline -------------- t t t t t t t t t t t f t t t t t t t t t t t (23 rows) |
pgxc_reset_planmgmt_hashtable()
描述:释放所有CN上plan management用于缓存outline所占用的内存。只能由数据库管理员用户,或授予了gs_role_sql_management角色权限的用户才可以执行。
返回值类型:boolean
示例:
查询当前各CN上plan management保存outline占用的内存情况。
1 2 3 4 5 6 7 8 9 10 11 12 |
SELECT pg_catalog.pgxc_node_str(), contextname, level, parent, pg_size_pretty(totalsize) totalsize, pg_size_pretty(freesize) freesize, pg_size_pretty(usedsize) usedsize FROM PG_SHARED_MEMORY_DETAIL WHERE contextname ilike 'plan%' ORDER BY contextname; pgxc_node_str | contextname | level | parent | totalsize | freesize | usedsize ---------------+----------------------------+-------+-----------------+-----------+----------+------------ coordinator1 | plan management hash table | 2 | PlanmgmtContext | 80 KB | 45 KB | 35 KB coordinator1 | PlanmgmtContext | 1 | ProcessMemory | 96 KB | 94 KB | 2432 bytes (2 rows) SELECT pgxc_reset_planmgmt_hashtable(); pgxc_reset_planmgmt_hashtable ------------------------------- t (1 row) |
执行pgxc_reset_planmgmt_hashtable()函数后,查询当前各CN上plan management保存outline占用的内存情况。
1 2 3 4 5 6 |
SELECT pg_catalog.pgxc_node_str(), contextname, level, parent, pg_size_pretty(totalsize) totalsize, pg_size_pretty(freesize) freesize, pg_size_pretty(usedsize) usedsize FROM PG_SHARED_MEMORY_DETAIL WHERE contextname ilike 'plan%' ORDER BY contextname; pgxc_node_str | contextname | level | parent | totalsize | freesize | usedsize ---------------+----------------------------+-------+-----------------+-----------+----------+---------- coordinator1 | plan management hash table | 2 | PlanmgmtContext | 56 KB | 33 KB | 23 KB coordinator1 | PlanmgmtContext | 1 | ProcessMemory | 0 bytes | 0 bytes | 0 bytes (2 rows) |