pg参数优先级
pg修改参数方式很多
配置文件,alter system,命令行,用户,数据库,所有用户,会话,事务,函数,表层面进行配置
下面为参数优先级,由低到高
1. postgresql.conf
work_mem = 4MB
2. postgresql.custom.conf
用户自定义参数文件,写在 postgresql.conf 末尾
include_if_exists 'postgresql.custom.conf'
work_mem = 5MB
3. postgresql.auto.conf
alter system set work_mem='6MB'
4. command line options
pg_ctl restart -o "-c work_mem='7MB'"
5. all role
alter role all set work_mem='8MB';
6. database
alter database testdb set work_mem='9MB';
7. role
alter role postgres set work_mem='10MB';
8. session
set work_mem='11MB';
9. 事务
begin;
set local work_mem='12MB';
10. function(函数内有效,函数结束,使用其他最高优先值)
create or replace function f_test() returns void as $$
declare
res text;
begin
show work_mem into res;
raise notice '%', res;
end;
$$ language plpgsql strict set work_mem='13MB';
11. table
autovacuum_enabled
所以,一般来说,pg的参数配置方式有很多
- 1.配置文件(postgresql.conf)
- 2.自定义配置文件(postgresql.custom.conf)
- 3.alter system(postgresql.auto.conf)
- 4.命令行(postgres -o, pg_ctl -o)
- 5.所有用户(alter role all set)
- 6.数据库(alter database xxx set)
- 7.用户(alter role 用户名 set)
- 8.会话(set xxx)
- 9.事务(set local xxx;)
- 10.函数(create or replace function .... set par=val;)
- 11.表(表级垃圾回收相关参数)
网友评论