Professional Documents
Culture Documents
https://pgtune.leopard.in.ua/#/
PostgreSQL cannot use a cache(shared buffer) bigger than 8GB as per rob and what he read in
PostgreSQL High Performance. ?
Shared buffers should be a quarter of total ram e.g with 32gb Ram its 8GB and I tested with 64GB and it
was 16GB
The number of connections are originally 100 but as you move up the RAM in increases.
work_mem is for sorting/complex sorts. How much memory do you want to
allocate for complex sorting. This work_mem is alloted for any query
that comes in. so roughly work_mem = 55924kB that is 55mb per query.
So if multiplied by max connections it can eat up a lot of memory.
http://www.craigkerstiens.com/2013/01/10/more-on-postgres-performance/
https://www.youtube.com/watch?v=fva7qn9Yg3o
Indexes ?
Installing pg_stat_statements
The pg_stat_statements module provides a means for tracking execution statistics of all SQL
statements executed by a server.
https://www.postgresql.org/docs/9.4/static/pgstatstatements.html
https://pganalyze.com/docs/install/01_enabling_pg_stat_statements/
Restart the PostgreSQL server
Top Queries
http://www.craigkerstiens.com/2013/01/10/more-on-postgres-performance/
SELECT
(total_time / 1000 / 60) as total_minutes,
(total_time/calls) as average_time,
query
FROM pg_stat_statements
ORDER BY 1 DESC
LIMIT 100;
Cache Usage
http://www.craigkerstiens.com/2012/10/01/understanding-postgres-performance/
SELECT
sum(heap_blks_read) as heap_read,
sum(heap_blks_hit) as heap_hit,
sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) as ratio
FROM
pg_statio_user_tables;
A cache hit ratio of 99% is good. Else if it’s lower increase your cache.
Index Usage