我很惊讶这个还没有发布.你知道博士后有什么有趣的技巧吗?模糊的配置选项和zoom /性能技巧尤其受欢迎.
我相信我们可以击败相应的MySQL thread条 comments 中的9条:)
我很惊讶这个还没有发布.你知道博士后有什么有趣的技巧吗?模糊的配置选项和zoom /性能技巧尤其受欢迎.
我相信我们可以击败相应的MySQL thread条 comments 中的9条:)
由于Postgres比MySQL理智得多,所以没有那么多"诀窍"可供报告;-)
manual有一些很好的performance条建议.
需要记住的其他一些与性能相关的事情:
以下是我发现的一些有用的东西,它们本身与配置或性能无关.
要查看当前发生的情况,请执行以下操作:
select * from pg_stat_activity;
搜索其他功能:
select * from pg_proc WHERE proname ~* '^pg_.*'
查找数据库的大小:
select pg_database_size('postgres');
select pg_size_pretty(pg_database_size('postgres'));
查找所有数据库的大小:
select datname, pg_size_pretty(pg_database_size(datname)) as size
from pg_database;
查找表和索引的大小:
select pg_size_pretty(pg_relation_size('public.customer'));
或者,要列出所有表和索引(可能更容易查看):
select schemaname, relname,
pg_size_pretty(pg_relation_size(schemaname || '.' || relname)) as size
from (select schemaname, relname, 'table' as type
from pg_stat_user_tables
union all
select schemaname, relname, 'index' as type
from pg_stat_user_indexes) x;
哦,您还可以嵌套事务,回滚部分事务++
test=# begin;
BEGIN
test=# select count(*) from customer where name='test';
count
-------
0
(1 row)
test=# insert into customer (name) values ('test');
INSERT 0 1
test=# savepoint foo;
SAVEPOINT
test=# update customer set name='john';
UPDATE 3
test=# rollback to savepoint foo;
ROLLBACK
test=# commit;
COMMIT
test=# select count(*) from customer where name='test';
count
-------
1
(1 row)