标签:资源分配 config val 最大值 sse 结束 insert nbsp 连接
devdw=# explain select * from tb_cp_02 t where t.id = 1;
QUERY PLAN
-----------------------------------------------------------------------------------
Gather Motion 1:1 (slice1; segments: 1) (cost=0.00..6.08 rows=7 width=22)
-> Append (cost=0.00..6.08 rows=4 width=22)
-> Seq Scan on tb_cp_02_1_prt_extra t (cost=0.00..2.08 rows=2 width=18)
Filter: id = 1
-> Seq Scan on tb_cp_02_1_prt_2 t (cost=0.00..1.00 rows=1 width=24)
Filter: id = 1
-> Seq Scan on tb_cp_02_1_prt_3 t (cost=0.00..1.00 rows=1 width=24)
Filter: id = 1
-> Seq Scan on tb_cp_02_1_prt_4 t (cost=0.00..1.00 rows=1 width=24)
Filter: id = 1
-> Seq Scan on tb_cp_02_1_prt_5 t (cost=0.00..1.00 rows=1 width=24)
Filter: id = 1
(12 rows)
devdw=# show resource_select_only;
resource_select_only
----------------------
off
(1 row)
max_resource_queues
– 最多资源队列数 max_resource_portals_per_transaction
– 事务最多打开的游标数 resource_cleanup_gangs_on_wait
– 开启新查询前清空队列中空闲进程 stats_queue_level
– 激活资源 gp_resqueue_memory_policy
– GP内存管理特性,默认是eager_free; statement_mem and max_statement_mem
– 每个活动语句内存分配量(可以覆盖资源队列的内存限制),前者默认200MB,后者默认2000MB; gp_vmem_protect_limit
– 所有segment实例可使用的物理内存总量,默认是8192M。 gp_vmem_idle_resource_timeout and gp_vmem_protect_segworker_cache_limit
– 用于释放被空间DB进程占用的内存,前者默认是18s,后者默认是500gp_resqueue_priority
– 开启优先级特性,默认是on; gp_resqueue_priority_sweeper_interval
– 设置CPU为所有语句重新计算CPU资源分配的时间,默认是1000; gp_resqueue_priority_cpucores_per_segment
– 设置每个实例使用的CPU,默认是4;可使用gpconfig命令来查看和修改工作负载配置参数
查看一个参数值
$ gpconfig –show gp_vmem_protect_limit
修改一个参数的值,且Master与Segment不同
$ gpconfig –c gp_resqueue_priority_cpucores_per_segment –v 2 –m 8
重启GP以确保修改的参数生效
$ gpstop –rf (加上f命令,将所有session都关闭)
=# CREATE RESOURCE QUEUE req_01 WITH (ACTIVE_STATEMENTS=2);
devdw=# create resource queue req_01 with (active_statements=2);
CREATE QUEUE
devdw=# select * from pg_resqueue;
rsqname | rsqcountlimit | rsqcostlimit | rsqovercommit | rsqignorecostlimit
------------+---------------+--------------+---------------+--------------------
req_01 | 2 | -1 | f | 0
pg_default |20 | -1 | f | 0
(2 rows)
=# CREATE RESOURCE QUEUE req_02 WITH (ACTIVE_STATEMENTS=10, MEMORY_LIMIT=‘2000MB’);
devdw=# CREATE RESOURCE QUEUE req_02 WITH (ACTIVE_STATEMENTS=10, MEMORY_LIMIT=‘200MBB‘);
CREATE QUEUE
devdw=# select * from pg_resqueue;
rsqname | rsqcountlimit | rsqcostlimit | rsqovercommit | rsqignorecostlimit
------------+---------------+--------------+---------------+--------------------
req_01 | 2 | -1 | f | 0
pg_default |20 | -1 | f | 0
req_02 |10 | -1 | f | 0
(3 rows)
=# CREATE RESOURCE QUEUE req_03 WITH (MAX_COST=1000000.0);
devdw=# CREATE RESOURCE QUEUE req_03 WITH (MAX_COST=1000000.0);
CREATE QUEUE
devdw=# select * from pg_resqueue;
rsqname | rsqcountlimit | rsqcostlimit | rsqovercommit | rsqignorecostlimit
------------+---------------+--------------+---------------+--------------------
req_01 | 2 | -1 | f | 0
pg_default |20 | -1 | f | 0
req_02 |10 | -1 | f | 0
req_03 |-1 |1e+06 | f | 0
(4 rows)
d) 允许系统空闲时执行语句
如果资源队列配置了Cost阀值,管理员可以允许COST_OVERCOMMIT,超过资源队列Cost阀值的语句可以被执行;
如果COST_OVERCOMMIT为false,超过cost阀值语句永远被拒绝。
e) 允许小查询绕过队列限制
可以设置MIN_COST指明什么样的开销作为小查询,那些低于MIN_COST的语句将立即得到执行。
MIN_COST不仅可以同MAX_COST一起使用,还可以和ACTIVE_STATEMENTS一起使用。例如,
=# CREATE RESOURCE QUEUE req_04 WITH (ACTIVE_STATEMENTS=10, MIN_COST=100.0);
devdw=# CREATE RESOURCE QUEUE req_04 WITH (ACTIVE_STATEMENTS=10, MIN_COST=100.0);
CREATE QUEUE
devdw=# select * from pg_resqueue;
rsqname | rsqcountlimit | rsqcostlimit | rsqovercommit | rsqignorecostlimit
------------+---------------+--------------+---------------+--------------------
req_01 | 2 | -1 | f | 0
pg_default |20 | -1 | f | 0
req_02 |10 | -1 | f | 0
req_03 |-1 |1e+06 | f | 0
req_04 |10 | -1 | f |100
=# CREATE RESOURCE QUEUE req_05 WITH (ACTIVE_STATEMENTS=3, PRIORITY=MAX);
devdw=# CREATE RESOURCE QUEUE req_05 WITH (ACTIVE_STATEMENTS=3, PRIORITY=MAX);
CREATE QUEUE
devdw=# select * from pg_resqueue;
rsqname | rsqcountlimit | rsqcostlimit | rsqovercommit | rsqignorecostlimit
------------+---------------+--------------+---------------+--------------------
req_01 | 2 | -1 | f | 0
pg_default |20 | -1 | f | 0
req_02 |10 | -1 | f | 0
req_03 |-1 |1e+06 | f | 0
req_04 |10 | -1 | f |100
req_05 | 3 | -1 | f | 0
(6 rows)
=# ALTER ROLE dylan RESOURCE QUEUE seq_01;
=# CREATE ROLE jack WITH LOGIN RESOURCE QUEUE seq_02;
devdw=# \du
List of roles
Role name | Attributes | Member of
-----------+--------------------------------------+-----------
admin | Create role, Create DB, Cannot login |
gpadmin | Superuser, Create role, Create DB|
mavshuang | | {admin}
devdw=# alter role mavshuang resource queue req_01;
ALTER ROLE
devdw=# create role jack with login resource queue req_02;
CREATE ROLE
devdw=# \du
List of roles
Role name | Attributes | Member of
-----------+--------------------------------------+-----------
admin | Create role, Create DB, Cannot login |
gpadmin | Superuser, Create role, Create DB|
jack | |
mavshuang | | {admin}
将ROLE从现有资源队列中移除并放到缺省队列中,
=# ALTER ROLE jack RESOURCE QUEUE none;
变更资源队列
a) 使用ALTER RESOURCE QUEUE命令来改变资源队列的限制
=# ALTER RESOURCE QUEUE req_01 WITH (ACTIVE_STATEMENTS=3);
=# ALTER RESOURCE QUEUE req_02 WITH (MAX_COST=100000.0);
b) 将活动语句数量或者内存限制重置为无限制,可以使用-1值。
=# ALTER RESOURCE QUEUE req_01 WITH (MAX_COST=-1.0, MEMORY_LIMIT=‘2GB’);
c) 改变查询优先级
=# ALTER RESOURCE QUEUE req_01 WITH (PRIORITY=MIN);
使用DROP RESOURCE QUEUE命令删除资源队列。
=# DROP RESOURCE QUEUE req_04;
=# SELECT rolname, rsqname
FROM pg_roles rol, gp_toolkit.gp_resqueue_status res
WHERE rol.rolresqueue=res.queueid;
4. 查看活动语句的优先级
使用gp_toolkit.gp_resq_priority_statement
视图
重置活动语句的优先级
5. SUPERUSER可以在语句运行期间通过内置函数gp_adjust_priority(session_id, statement_count
调整优先级。例如,
select gp_adjust_priority(752,24905,‘HIGH‘);
该语句只对指定的语句有效,同一资源队列随后的语句仍然使用其预先设定的优先级
(原文地址:http://blog.csdn.net/mavs41/article/details/51973908)
标签:资源分配 config val 最大值 sse 结束 insert nbsp 连接
原文地址:http://www.cnblogs.com/jianyungsun/p/6627562.html