SlideShare uma empresa Scribd logo
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
PRACTICAL MEMORY
TUNING FOR
POSTGRESQL
Grant McAlister
Senior Principal Engineer
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Why you should care
0
10,000
20,000
30,000
40,000
50,000
60,000
70,000
5 105 205 305 405 505 605 705 805 905 1005 1105 1205 1305 1405 1505 1605 1705
Transactions
Per
Second
(TPS)
Seconds
sysbench read only point selects
Normal Tuning Less than Optimal Tuning
11X
buffers not in memory swap thrashing
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
OOM & Swap
3
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
What is the Out of Memory (OOM) Killer
postgres 1
postgres 2
postgres 3
postgres 4
badness_for_task = total_vm_for_task / (sqrt(cpu_time_in_seconds) * sqrt(sqrt(cpu_time_in_minutes)))
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
What is the Out of Memory (OOM) Killer
postgres 1
postgres 2
postgres 3
postgres 4
badness_for_task = total_vm_for_task / (sqrt(cpu_time_in_seconds) * sqrt(sqrt(cpu_time_in_minutes)))
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Why swap?
RAM
request 8k
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Why swap?
RAM
request 16k
FULL
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Why swap?
RAM SWAP
request 16k
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Why swap?
RAM SWAP
request 16k
swap out
swap in
THRASHING
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Overview
6
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Memory Overview
Operating System
shared_buffers
postgres
processes
pagecache
25%
Operating System
shared_buffers
postgres
processes
pagecache
75%
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pagecache
File System Cache
Storage
shared_buffers wal archiving misc temp_buffers
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pagecache
File System Cache
Storage
shared_buffers wal archiving misc temp_buffers
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pagecache
File System Cache
Storage
shared_buffers wal archiving misc
shared_buffers
wal
archiving
misc
temp_buffers
temp_buffers
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Pagecache
File System Cache
Storage
shared_buffers wal archiving misc
shared_buffers
wal
archiving
misc
temp_buffers
temp_buffers
shared_buffers
misc temp_buffers
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Working Set Size - Heat
Orders_2023
Orders_2022
Orders_2021
Orders_2020
Orders_2019
Orders_2018
Orders_2017
Orders_2016
800GB
80-100GB hot working set
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Inventory_SEA
Inventory_LAX
Inventory_SFO
Inventory_EWR
Inventory_SYD
Inventory_YYC
Inventory_BIO
Inventory_SBP
Working Set Size - Heat
Orders_2023
Orders_2022
Orders_2021
Orders_2020
Orders_2019
Orders_2018
Orders_2017
Orders_2016
800GB
80-100GB hot working set
Inventory_SEA
Inventory_LAX
Inventory_SFO
Inventory_EWR
Inventory_SYD
Inventory_YYC
Inventory_BIO
Inventory_SBP
800GB
200-400GB hot working set
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Working Set Size – Indexes and Data
Random
heap
index
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Working Set Size – Indexes and Data
Random
heap
index
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Working Set Size – Indexes and Data
Random
heap
index
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Working Set Size – Indexes and Data
Random
heap
index
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Working Set Size – Indexes and Data
right leaning
heap
index
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Working Set Size – Indexes and Data
right leaning
heap
index
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Working Set Size – Indexes and Data
right leaning
heap
index
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Working Set Size – Indexes and Data
right leaning
heap
index
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Shared Buffers
12
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Small Cache
File System Cache
Storage
shared_buffers
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
shared_buffers comparison
14
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%
0
100,000
200,000
300,000
400,000
500,000
600,000
700,000
800,000
900,000
25% of host memory - 80
tables
25% of host memory - 125
tables
25% of host memory - 250
tables
12.5% of host memory -
250 tables
5% of host memory - 250
tables
1% of host memory - 250
tables
Percent
of
object
type
in
memory
Transactions
Per
Second sysbench - read only point selects
TPS Index Tables
60%
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
shared_buffers comparison – pg_buffercache
Type
Usage
count
25% of host
memory
1% of host
memory
Index 5 855806 3630
Index 4 707472 2624
Index 3 124292 23
Index 2 22019 1754
Index 1 3799 73303
Index 0 558 71569
Table 5 316 1
Table 4 2764 3
Table 3 33572 105
Table 2 359638 180
Table 1 2933760 76505
Table 0 2606002 76303
15
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
shared_buffers comparison – pg_buffercache
Type
Usage
count
25% of host
memory
1% of host
memory
Index 5 855806 3630
Index 4 707472 2624
Index 3 124292 23
Index 2 22019 1754
Index 1 3799 73303
Index 0 558 71569
Table 5 316 1
Table 4 2764 3
Table 3 33572 105
Table 2 359638 180
Table 1 2933760 76505
Table 0 2606002 76303
15
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Big Cache
File System Cache
Storage
shared_buffers
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Big Cache
File System Cache
Storage
shared_buffers
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Big Cache
File System Cache
Storage
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Big Cache
File System Cache
Storage
shared_buffers
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Big Cache
File System Cache
Storage
shared_buffers
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
HugePages
17
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Why HugePages – page mapping
18
PageTables shared_buffers
pg 1
pg 2
pg 3
4k
4k
size of page table = # of PostgreSQL process X amount of shared buffers accessed
2M
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 19
0
10,000
20,000
30,000
40,000
50,000
60,000
70,000
5
30
55
80
105
130
155
180
205
230
255
280
305
330
355
380
405
430
455
480
505
530
555
580
605
630
655
680
705
730
755
780
805
830
855
880
905
930
955
980
1005
1030
1055
1080
1105
1130
1155
1180
1205
1230
1255
1280
1305
1330
1355
1380
1405
1430
1455
1480
1505
1530
1555
1580
1605
1630
1655
1680
1705
1730
1755
1780
Transactions
Per
Second
(TPS)
Seconds
Sysbench Read Only Point Selects – r6i.8xlarge – 250 tables x 2.5M rows – 160GB
250 Client Hupepage=on 250 Client Hupepage=off
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 20
0
10,000
20,000
30,000
40,000
50,000
60,000
70,000
5
30
55
80
105
130
155
180
205
230
255
280
305
330
355
380
405
430
455
480
505
530
555
580
605
630
655
680
705
730
755
780
805
830
855
880
905
930
955
980
1005
1030
1055
1080
1105
1130
1155
1180
1205
1230
1255
1280
1305
1330
1355
1380
1405
1430
1455
1480
1505
1530
1555
1580
1605
1630
1655
1680
1705
1730
1755
1780
Transactions
Per
Second
(TPS)
Seconds
Sysbench Read Only Point Selects – r6i.8xlarge – 250 tables x 2.5M rows – 160GB
500 Client Hupepage=on 500 Client Hupepage=off
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 21
0
10,000
20,000
30,000
40,000
50,000
60,000
70,000
5
30
55
80
105
130
155
180
205
230
255
280
305
330
355
380
405
430
455
480
505
530
555
580
605
630
655
680
705
730
755
780
805
830
855
880
905
930
955
980
1005
1030
1055
1080
1105
1130
1155
1180
1205
1230
1255
1280
1305
1330
1355
1380
1405
1430
1455
1480
1505
1530
1555
1580
1605
1630
1655
1680
1705
1730
1755
1780
Transactions
Per
Second
(TPS)
Seconds
Sysbench Read Only Point Selects – r6i.8xlarge – 250 tables x 2.5M rows – 160GB
1000 Client Hupepage=on 1000 Client Hupepage=off
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Cost of not setting HugePages
22
0%
5%
10%
15%
20%
25%
30%
35%
40%
45%
50%
0
20
40
60
80
100
120
140
250 500 1000
Percent
of
host
memory
GB
of
PageTable
number of postgreSQL process
sysbench read only - shard_buffer=25% of ram
PageTables size (gb) % of host memory
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Per Session
23
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
temp_buffers
shared_buffers temp_buffers
File System Cache
regular tables temp tables
global session
local
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SQL Stream
logical_decoding_work_mem
OLTP
DW
SQL Stream
logical
decoding
slot
wal
log
DW2
logical
decoding
slot
SQL Stream
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Per Session Operation
26
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
work_mem
postgres=# set work_mem TO '1 GB’;
postgres=# explain analyze
select mykey::bigint, (random()*10000000000)::bigint as scratch ,
repeat('X', 1024)::char(1024) filler from generate_series(1,3800000)
as mykey order by scratch;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------
-
Sort (cost=7219224.79..7228724.79 rows=3800000 width=4116) (actual time=7083.506..8358.093 rows=3800000 loops=1)
Sort Key: (((random() * '10000000000'::double precision))::bigint)
Sort Method: external merge Disk: 3919000kB
-> Function Scan on generate_series mykey (cost=0.00..76000.00 rows=3800000 width=4116) (actual time=194.053..493.117 rows=3800000 loops=1)
Planning Time: 0.049 ms
Execution Time: 9117.344 ms
(6 rows)
~3.8GB
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 28
0
1
2
3
4
5
6
7
8
9
10
1 6 11 16 21 26 31 36 41 46 51 56
GB
RAM
Seconds
work_mem - sorting
1GB work_mem 3.8GB query
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
work_mem
postgres=# set work_mem TO '4 GB’;
postgres=# explain analyze
select mykey::bigint, (random()*10000000000)::bigint as scratch ,
repeat('X', 1024)::char(1024) filler from generate_series(1,3800000)
as mykey order by scratch;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------
-
Sort (cost=7219224.79..7228724.79 rows=3800000 width=4116) (actual time=2766.682..3408.706 rows=3800000 loops=1)
Sort Key: (((random() * '10000000000'::double precision))::bigint)
Sort Method: quicksort Memory: 4128025kB
-> Function Scan on generate_series mykey (cost=0.00..76000.00 rows=3800000 width=4116) (actual time=194.365..506.965 rows=3800000 loops=1)
Planning Time: 0.047 ms
Execution Time: 3825.965 ms
(6 rows)
~3.8GB
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 30
0
1
2
3
4
5
6
7
8
9
10
1 6 11 16 21 26 31 36 41 46 51 56
GB
RAM
Seconds
work_mem - sorting
4GB work_mem - 3.8GB query 1GB work_mem 3.8GB query
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
work_mem
postgres=# set work_mem TO '4 GB’;
explain analyze select s1.filler, s2.filler,s1.mykey, s2.mykey, s1.scratch, s2.scratch from
(select mykey::bigint, (random()*1000000000)::bigint as scratch ,
repeat('X', 1024)::char(1024) filler from generate_series(1,3800000)
as mykey order by scratch) s1,
(select mykey::bigint, (random()*10000000000)::bigint as scratch ,
repeat('X', 1024)::char(1024) filler from generate_series(1,3800000)
as mykey order by scratch) s2
where s1.scratch=s2.scratch order by s1.mykey;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------
---------------------
Sort (cost=523467712452.33..523648212452.33 rows=72200000000 width=8232) (actual time=6851.977..6852.172 rows=1494 loops=1)
Sort Key: ((mykey.mykey)::bigint)
Sort Method: quicksort Memory: 3153kB
-> Merge Join (cost=14438449.59..1097542949.59 rows=72200000000 width=8232) (actual time=5558.904..6850.847 rows=1494 loops=1)
Merge Cond: ((((random() * '1000000000'::double precision))::bigint) = (((random() * '10000000000'::double precision))::bigint))
-> Sort (cost=7219224.79..7228724.79 rows=3800000 width=4116) (actual time=2785.745..3524.489 rows=3800000 loops=1)
Sort Key: (((random() * '1000000000'::double precision))::bigint)
Sort Method: quicksort Memory: 4128025kB
-> Function Scan on generate_series mykey (cost=0.00..76000.00 rows=3800000 width=4116) (actual time=194.222..515.986
rows=3800000 loops=1)
-> Materialize (cost=7219224.79..7276224.79 rows=3800000 width=4116) (actual time=2772.383..2961.007 rows=380357 loops=1)
-> Sort (cost=7219224.79..7228724.79 rows=3800000 width=4116) (actual time=2772.377..2867.394 rows=380353 loops=1)
Sort Key: (((random() * '10000000000'::double precision))::bigint)
Sort Method: quicksort Memory: 4128025kB
-> Function Scan on generate_series mykey_1 (cost=0.00..76000.00 rows=3800000 width=4116) (actual time=198.688..511.083
rows=3800000 loops=1)
Planning Time: 0.098 ms
Execution Time: 7511.377 ms
~3.8GB
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 32
0
1
2
3
4
5
6
7
8
9
10
1 6 11 16 21 26 31 36 41 46 51 56
GB
RAM
Seconds
work_mem - sorting
4GB work_mem - 7.6GB+ query 4GB work_mem - 3.8GB query
1GB work_mem 3.8GB query
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
work_mem
postgres=# set work_mem TO '4 GB’;
postgres=# explain analyze
select s1.filler, s2.filler,s1.mykey, s2.mykey, s1.scratch, s2.scratch from
(select mykey::bigint, (random()*1000000000)::bigint as scratch ,
repeat('X', 1024)::char(1024) filler from generate_series(1,18800000)
as mykey order by scratch) s1,
(select mykey::bigint, (random()*10000000000)::bigint as scratch ,
repeat('X', 1024)::char(1024) filler from generate_series(1,3800000)
as mykey order by scratch) s2
where s1.scratch=s2.scratch order by s1.mykey;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------
Sort (cost=3853846009559.71..3854739009559.71 rows=357200000000 width=8232) (actual time=52689.953..52690.952 rows=7184 loops=1)
Sort Key: ((mykey_1.mykey)::bigint)
Sort Method: quicksort Memory: 15122kB
-> Merge Join (cost=43152211.85..5401444211.85 rows=357200000000 width=8232) (actual time=42991.198..52679.295 rows=7184 loops=1)
Merge Cond: ((((random() * '10000000000'::double precision))::bigint) = (((random() * '1000000000'::double precision))::bigint))
-> Sort (cost=7219224.79..7228724.79 rows=3800000 width=4116) (actual time=2771.496..2877.777 rows=380382 loops=1)
Sort Key: (((random() * '10000000000'::double precision))::bigint)
Sort Method: quicksort Memory: 4128025kB
-> Function Scan on generate_series mykey (cost=0.00..76000.00 rows=3800000 width=4116) (actual time=194.404..516.400
rows=3800000 loops=1)
-> Materialize (cost=35932987.06..36214987.06 rows=18800000 width=4116) (actual time=40218.833..48614.865 rows=18800001 loops=1)
-> Sort (cost=35932987.06..35979987.06 rows=18800000 width=4116) (actual time=40218.824..46815.209 rows=18800000 loops=1)
Sort Key: (((random() * '1000000000'::double precision))::bigint)
Sort Method: external merge Disk: 19388680kB
-> Function Scan on generate_series mykey_1 (cost=0.00..376000.00 rows=18800000 width=4116) (actual
time=960.638..2593.178 rows=18800000 loops=1)
Planning Time: 0.102 ms
Execution Time: 55724.412 ms
~3.8GB
~18.8GB
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 34
0
1
2
3
4
5
6
7
8
9
10
1 6 11 16 21 26 31 36 41 46 51 56
GB
RAM
Seconds
work_mem - sorting
4GB work_mem - 18.8GB+ query 4GB work_mem - 7.6GB+ query
4GB work_mem - 3.8GB query 1GB work_mem 3.8GB query
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
hash_mem_multiplier
postgres=# show hash_mem_multiplier;
hash_mem_multiplier
---------------------
2
postgres=# set work_mem=‘4 GB';
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Hash Join (cost=2083766.00..5865195158.01 rows=167200000000 width=8232) (actual time=4360.794..16414.748 rows=3344 loops=1)
Hash Cond: (s1.scratch = s2.scratch)
-> Subquery Scan on s1 (cost=0.00..264000.00 rows=8800000 width=4116) (actual time=374.153..1692.160 rows=8800000 loops=1)
-> Function Scan on generate_series mykey (cost=0.00..176000.00 rows=8800000 width=4116) (actual time=374.152..1161.469 rows=8800000 loops=1)
-> Hash (cost=114000.00..114000.00 rows=3800000 width=4116) (actual time=3982.004..3982.006 rows=3800000 loops=1)
Buckets: 2097152 Batches: 2 Memory Usage: 2020102kB
-> Subquery Scan on s2 (cost=0.00..114000.00 rows=3800000 width=4116) (actual time=186.934..742.574 rows=3800000 loops=1)
-> Function Scan on generate_series mykey_1 (cost=0.00..76000.00 rows=3800000 width=4116) (actual time=186.932..515.290 rows=3800000 loops=1)
Planning Time: 0.090 ms
Execution Time: 16655.195 ms
(10 rows)
postgres=# set work_mem='1 GB';
SET
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Hash Join (cost=2083766.00..5865195158.01 rows=167200000000 width=8232) (actual time=5099.725..23063.116 rows=3575 loops=1)
Hash Cond: (s1.scratch = s2.scratch)
-> Subquery Scan on s1 (cost=0.00..264000.00 rows=8800000 width=4116) (actual time=376.939..1651.354 rows=8800000 loops=1)
-> Function Scan on generate_series mykey (cost=0.00..176000.00 rows=8800000 width=4116) (actual time=376.937..1119.345 rows=8800000 loops=1)
-> Hash (cost=114000.00..114000.00 rows=3800000 width=4116) (actual time=4714.890..4714.891 rows=3800000 loops=1)
Buckets: 524288 Batches: 8 Memory Usage: 505086kB
-> Subquery Scan on s2 (cost=0.00..114000.00 rows=3800000 width=4116) (actual time=181.422..740.776 rows=3800000 loops=1)
-> Function Scan on generate_series mykey_1 (cost=0.00..76000.00 rows=3800000 width=4116) (actual time=181.420..512.871 rows=3800000 loops=1)
Planning Time: 0.089 ms
Execution Time: 23186.765 ms
~2.6GB – 16.6 seconds
~1.2GB – 23.1 seconds
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Per Session Item
36
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
prepared statements
PREPARE sbtestplan (int) AS
SELECT * FROM sbtest1 WHERE id=$1 ;
EXECUTE sbtestplan(1);
sbtest=# SELECT name, ident, level, total_bytes
FROM pg_backend_memory_contexts where name ='CachedPlanSource';
name | ident | level | total_bytes
------------------+-----------------------------------------+-------+-------------
CachedPlanSource | PREPARE sbtestplan3 (int) AS +| 2 | 4096
| SELECT * FROM sbtest3 WHERE id=$1 ; | |
CachedPlanSource | PREPARE sbtestplan2 (int) AS +| 2 | 4096
| SELECT * FROM sbtest2 WHERE id=$1 ; | |
CachedPlanSource | PREPARE sbtestplan (int) AS +| 2 | 4096
| SELECT * FROM sbtest1 WHERE id=$1 ; | |
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
prepared statements – 10 Million
38
0
20
40
60
80
100
1
7
13
19
25
31
37
43
49
55
61
67
73
79
85
91
97
103
109
115
121
127
133
139
145
151
157
163
169
175
181
187
193
199
205
211
217
223
229
235
241
247
253
259
265
271
277
283
289
295
301
307
313
319
325
331
337
343
349
355
361
GB
Used
Seconds
10 million prepared statements - 1 client
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Maintenance
39
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
maintenance_work_mem – Index builds
sbtest=# set maintenance_work_mem = '1 GB';
^
sbtest=# create index foo on sbtest1 (id,c,pad,k desc) ;
CREATE INDEX
Time: 45803.577 ms (00:45.804)
sbtest=# set maintenance_work_mem = '2 GB';
sbtest=# create index foo on sbtest1 (id,c,pad,k desc) ;
CREATE INDEX
Time: 45904.760 ms (00:45.905)
sbtest=# set maintenance_work_mem = '4 GB';
sbtest=# create index foo on sbtest1 (id,c,pad,k desc) ;
CREATE INDEX
Time: 46081.414 ms (00:46.081)
~1GB
~2GB
~3GB
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
maintenance_work_mem – how vacuum works
heap
index
index
vacuum
scan heap
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
maintenance_work_mem – how vacuum works
heap
index
index
vacuum
maintenance_work_mem
tid to clean
scan heap
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
maintenance_work_mem – how vacuum works
heap
index
index
vacuum
maintenance_work_mem
tid to clean
scan heap scan indexes
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
maintenance_work_mem - vacuum
sbtest=# set maintenance_work_mem='100 MB';
sbtest=# vacuum (verbose) sbtest1;
INFO: vacuuming "sbtest.public.sbtest1"
INFO: launched 1 parallel vacuum worker for index vacuuming (planned: 1)
INFO: launched 1 parallel vacuum worker for index vacuuming (planned: 1)
INFO: finished vacuuming "sbtest.public.sbtest1": index scans: 2
pages: 0 removed, 13921343 remain, 13921343 scanned (100.00% of total)
tuples: 11014287 removed, 500000000 remain, 0 are dead but not yet removable
removable cutoff: 74587243, which was 0 XIDs old when operation ended
index scan needed: 11236460 pages from table (80.71% of total) had 18915133 dead item identifiers removed
index "sbtest1_pkey": pages: 1370933 in total, 0 newly deleted, 0 currently deleted, 0 reusable
index "k_1": pages: 1202589 in total, 0 newly deleted, 0 currently deleted, 0 reusable
avg read rate: 102.408 MB/s, avg write rate: 99.348 MB/s
buffer usage: 16918231 hits, 24908382 misses, 24164093 dirtied
WAL usage: 48871286 records, 26289264 full page images, 210588376068 bytes
system usage: CPU: user: 184.21 s, system: 275.86 s, elapsed: 1900.21 s
VACUUM
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
maintenance_work_mem - vacuum
sbtest=# set maintenance_work_mem='1 GB’;
sbtest=# vacuum (verbose) sbtest1;
INFO: vacuuming "sbtest.public.sbtest1"
INFO: launched 1 parallel vacuum worker for index vacuuming (planned: 1)
INFO: finished vacuuming "sbtest.public.sbtest1": index scans: 1
pages: 0 removed, 13921343 remain, 13921343 scanned (100.00% of total)
tuples: 10990324 removed, 500000000 remain, 0 are dead but not yet removable
removable cutoff: 103987274, which was 0 XIDs old when operation ended
new relfrozenxid: 53987274, which is 11901571 XIDs ahead of previous value
index scan needed: 10126301 pages from table (72.74% of total) had 16347414 dead item identifiers removed
index "sbtest1_pkey": pages: 1370933 in total, 0 newly deleted, 0 currently deleted, 0 reusable
index "k_1": pages: 1202589 in total, 0 newly deleted, 0 currently deleted, 0 reusable
avg read rate: 90.361 MB/s, avg write rate: 101.013 MB/s
buffer usage: 16700415 hits, 22645066 misses, 25314603 dirtied
WAL usage: 63975507 records, 26568355 full page images, 219969619018 bytes
system usage: CPU: user: 195.27 s, system: 265.41 s, elapsed: 1957.86 s
VACUUM
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
maintenance_work_mem - vacuum parallel
sbtest=# set maintenance_work_mem='1 GB’;
sbtest=# vacuum (verbose) sbtest1;
INFO: vacuuming "sbtest.public.sbtest1"
INFO: launched 2 parallel vacuum workers for index vacuuming (planned: 2)
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
autovacuum_work_mem
max mem = autovacuum_work_mem X autovacuum_max_workers
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Why you should care
0
10,000
20,000
30,000
40,000
50,000
60,000
70,000
5 105 205 305 405 505 605 705 805 905 1005 1105 1205 1305 1405 1505 1605 1705
Transactions
Per
Second
(TPS)
Seconds
sysbench read only point selects
Normal Tuning Less than Optimal Tuning
11X
buffers not in memory swap thrashing
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Thank you!
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Grant McAlister

Mais conteúdo relacionado

Mais procurados

Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...
Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...
Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...
Amazon Web Services
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
Dongmin Yu
 
PostgreSQL
PostgreSQLPostgreSQL
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Henning Jacobs
 
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
ScyllaDB
 
2020.02.06 우리는 왜 glue를 버렸나?
2020.02.06 우리는 왜 glue를 버렸나?2020.02.06 우리는 왜 glue를 버렸나?
2020.02.06 우리는 왜 glue를 버렸나?
Thomas Hyun (동현) Park
 
Dapr - A 10x Developer Framework for Any Language
Dapr - A 10x Developer Framework for Any LanguageDapr - A 10x Developer Framework for Any Language
Dapr - A 10x Developer Framework for Any Language
Bilgin Ibryam
 
Aurora Serverless: Scalable, Cost-Effective Application Deployment (DAT336) -...
Aurora Serverless: Scalable, Cost-Effective Application Deployment (DAT336) -...Aurora Serverless: Scalable, Cost-Effective Application Deployment (DAT336) -...
Aurora Serverless: Scalable, Cost-Effective Application Deployment (DAT336) -...
Amazon Web Services
 
Query logging with proxysql
Query logging with proxysqlQuery logging with proxysql
Query logging with proxysql
YoungHeon (Roy) Kim
 
re:Invent 2022 DAT326 Deep dive into Amazon Aurora and its innovations
re:Invent 2022  DAT326 Deep dive into Amazon Aurora and its innovationsre:Invent 2022  DAT326 Deep dive into Amazon Aurora and its innovations
re:Invent 2022 DAT326 Deep dive into Amazon Aurora and its innovations
Grant McAlister
 
Programming in Spark using PySpark
Programming in Spark using PySpark      Programming in Spark using PySpark
Programming in Spark using PySpark
Mostafa
 
AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기
AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기
AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기
Amazon Web Services Korea
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability Patterns
Jonas Bonér
 
Monitoring Microservices
Monitoring MicroservicesMonitoring Microservices
Monitoring Microservices
Weaveworks
 
OSMC 2022 | The Power of Metrics, Logs & Traces with Open Source by Emil-Andr...
OSMC 2022 | The Power of Metrics, Logs & Traces with Open Source by Emil-Andr...OSMC 2022 | The Power of Metrics, Logs & Traces with Open Source by Emil-Andr...
OSMC 2022 | The Power of Metrics, Logs & Traces with Open Source by Emil-Andr...
NETWAYS
 
Aurora Deep Dive | AWS Floor28
Aurora Deep Dive | AWS Floor28Aurora Deep Dive | AWS Floor28
Aurora Deep Dive | AWS Floor28
Amazon Web Services
 
Delta Architecture
Delta ArchitectureDelta Architecture
Delta Architecture
Paulo Gutierrez
 
Optimizing Network Performance for Amazon EC2 Instances (CMP308-R1) - AWS re:...
Optimizing Network Performance for Amazon EC2 Instances (CMP308-R1) - AWS re:...Optimizing Network Performance for Amazon EC2 Instances (CMP308-R1) - AWS re:...
Optimizing Network Performance for Amazon EC2 Instances (CMP308-R1) - AWS re:...
Amazon Web Services
 
postgres_빌드_및_디버깅.pdf
postgres_빌드_및_디버깅.pdfpostgres_빌드_및_디버깅.pdf
postgres_빌드_및_디버깅.pdf
Lee Dong Wook
 
MariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationMariaDB Galera Cluster presentation
MariaDB Galera Cluster presentation
Francisco Gonçalves
 

Mais procurados (20)

Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...
Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...
Amazon DynamoDB Under the Hood: How We Built a Hyper-Scale Database (DAT321) ...
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
 
PostgreSQL
PostgreSQLPostgreSQL
PostgreSQL
 
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
 
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1Scylla Summit 2022: Scylla 5.0 New Features, Part 1
Scylla Summit 2022: Scylla 5.0 New Features, Part 1
 
2020.02.06 우리는 왜 glue를 버렸나?
2020.02.06 우리는 왜 glue를 버렸나?2020.02.06 우리는 왜 glue를 버렸나?
2020.02.06 우리는 왜 glue를 버렸나?
 
Dapr - A 10x Developer Framework for Any Language
Dapr - A 10x Developer Framework for Any LanguageDapr - A 10x Developer Framework for Any Language
Dapr - A 10x Developer Framework for Any Language
 
Aurora Serverless: Scalable, Cost-Effective Application Deployment (DAT336) -...
Aurora Serverless: Scalable, Cost-Effective Application Deployment (DAT336) -...Aurora Serverless: Scalable, Cost-Effective Application Deployment (DAT336) -...
Aurora Serverless: Scalable, Cost-Effective Application Deployment (DAT336) -...
 
Query logging with proxysql
Query logging with proxysqlQuery logging with proxysql
Query logging with proxysql
 
re:Invent 2022 DAT326 Deep dive into Amazon Aurora and its innovations
re:Invent 2022  DAT326 Deep dive into Amazon Aurora and its innovationsre:Invent 2022  DAT326 Deep dive into Amazon Aurora and its innovations
re:Invent 2022 DAT326 Deep dive into Amazon Aurora and its innovations
 
Programming in Spark using PySpark
Programming in Spark using PySpark      Programming in Spark using PySpark
Programming in Spark using PySpark
 
AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기
AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기
AWS Summit Seoul 2023 | 실시간 CDC 데이터 처리! Modern Transactional Data Lake 구축하기
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability Patterns
 
Monitoring Microservices
Monitoring MicroservicesMonitoring Microservices
Monitoring Microservices
 
OSMC 2022 | The Power of Metrics, Logs & Traces with Open Source by Emil-Andr...
OSMC 2022 | The Power of Metrics, Logs & Traces with Open Source by Emil-Andr...OSMC 2022 | The Power of Metrics, Logs & Traces with Open Source by Emil-Andr...
OSMC 2022 | The Power of Metrics, Logs & Traces with Open Source by Emil-Andr...
 
Aurora Deep Dive | AWS Floor28
Aurora Deep Dive | AWS Floor28Aurora Deep Dive | AWS Floor28
Aurora Deep Dive | AWS Floor28
 
Delta Architecture
Delta ArchitectureDelta Architecture
Delta Architecture
 
Optimizing Network Performance for Amazon EC2 Instances (CMP308-R1) - AWS re:...
Optimizing Network Performance for Amazon EC2 Instances (CMP308-R1) - AWS re:...Optimizing Network Performance for Amazon EC2 Instances (CMP308-R1) - AWS re:...
Optimizing Network Performance for Amazon EC2 Instances (CMP308-R1) - AWS re:...
 
postgres_빌드_및_디버깅.pdf
postgres_빌드_및_디버깅.pdfpostgres_빌드_및_디버깅.pdf
postgres_빌드_및_디버깅.pdf
 
MariaDB Galera Cluster presentation
MariaDB Galera Cluster presentationMariaDB Galera Cluster presentation
MariaDB Galera Cluster presentation
 

Semelhante a Practical Memory Tuning for PostgreSQL

Deep Dive on Amazon Aurora with PostgreSQL Compatibility (DAT305-R1) - AWS re...
Deep Dive on Amazon Aurora with PostgreSQL Compatibility (DAT305-R1) - AWS re...Deep Dive on Amazon Aurora with PostgreSQL Compatibility (DAT305-R1) - AWS re...
Deep Dive on Amazon Aurora with PostgreSQL Compatibility (DAT305-R1) - AWS re...
Amazon Web Services
 
Speed up your Machine Learning workflows with build-in algorithms
Speed up your Machine Learning workflows with build-in algorithmsSpeed up your Machine Learning workflows with build-in algorithms
Speed up your Machine Learning workflows with build-in algorithms
Julien SIMON
 
Speed up your Machine Learning workflows with built-in algorithms - Tel Aviv ...
Speed up your Machine Learning workflows with built-in algorithms - Tel Aviv ...Speed up your Machine Learning workflows with built-in algorithms - Tel Aviv ...
Speed up your Machine Learning workflows with built-in algorithms - Tel Aviv ...
Amazon Web Services
 
Dat305 Deep Dive on Amazon Aurora PostgreSQL
Dat305 Deep Dive on Amazon Aurora PostgreSQLDat305 Deep Dive on Amazon Aurora PostgreSQL
Dat305 Deep Dive on Amazon Aurora PostgreSQL
Grant McAlister
 
Migrating Oracle to Aurora PostgreSQL Utilizing AWS Database Migration Servic...
Migrating Oracle to Aurora PostgreSQL Utilizing AWS Database Migration Servic...Migrating Oracle to Aurora PostgreSQL Utilizing AWS Database Migration Servic...
Migrating Oracle to Aurora PostgreSQL Utilizing AWS Database Migration Servic...
Amazon Web Services
 
Amazon DocumentDB - Architecture 및 Best Practice (Level 200) - 발표자: 장동훈, Sr. ...
Amazon DocumentDB - Architecture 및 Best Practice (Level 200) - 발표자: 장동훈, Sr. ...Amazon DocumentDB - Architecture 및 Best Practice (Level 200) - 발표자: 장동훈, Sr. ...
Amazon DocumentDB - Architecture 및 Best Practice (Level 200) - 발표자: 장동훈, Sr. ...
Amazon Web Services Korea
 
Machine Learning with Amazon SageMaker - Algorithms and Frameworks - BDA304 -...
Machine Learning with Amazon SageMaker - Algorithms and Frameworks - BDA304 -...Machine Learning with Amazon SageMaker - Algorithms and Frameworks - BDA304 -...
Machine Learning with Amazon SageMaker - Algorithms and Frameworks - BDA304 -...
Amazon Web Services
 
Build on Amazon Aurora with MySQL Compatibility (DAT348-R4) - AWS re:Invent 2018
Build on Amazon Aurora with MySQL Compatibility (DAT348-R4) - AWS re:Invent 2018Build on Amazon Aurora with MySQL Compatibility (DAT348-R4) - AWS re:Invent 2018
Build on Amazon Aurora with MySQL Compatibility (DAT348-R4) - AWS re:Invent 2018
Amazon Web Services
 
AWS Container services
AWS Container servicesAWS Container services
AWS Container services
Aleksandr Maklakov
 
AWS Startup Day Kyiv: Container services on AWS. Comparing Amazon ECS, AWS Fa...
AWS Startup Day Kyiv: Container services on AWS. Comparing Amazon ECS, AWS Fa...AWS Startup Day Kyiv: Container services on AWS. Comparing Amazon ECS, AWS Fa...
AWS Startup Day Kyiv: Container services on AWS. Comparing Amazon ECS, AWS Fa...
Amazon Web Services
 
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech TalksElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
Amazon Web Services
 
SRV308 Deep Dive on Amazon Aurora
SRV308 Deep Dive on Amazon AuroraSRV308 Deep Dive on Amazon Aurora
SRV308 Deep Dive on Amazon Aurora
Amazon Web Services
 
Amazon Aurora
Amazon AuroraAmazon Aurora
Amazon Aurora
Amazon Web Services
 
Amazon Aurora - Rajeev Chakrabarti
Amazon Aurora - Rajeev ChakrabartiAmazon Aurora - Rajeev Chakrabarti
Amazon Aurora - Rajeev Chakrabarti
Amazon Web Services
 
AWS Lambda Powertools walkthrough.pdf
AWS Lambda Powertools walkthrough.pdfAWS Lambda Powertools walkthrough.pdf
AWS Lambda Powertools walkthrough.pdf
Heitor Lessa
 
How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...
How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...
How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...
Amazon Web Services
 
Full Page Writes in PostgreSQL PGCONFEU 2022
Full Page Writes in PostgreSQL PGCONFEU 2022Full Page Writes in PostgreSQL PGCONFEU 2022
Full Page Writes in PostgreSQL PGCONFEU 2022
Grant McAlister
 
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
Amazon Web Services
 
[NEW LAUNCH!] Introducing Amazon Managed Streaming for Kafka (Amazon MSK) (AN...
[NEW LAUNCH!] Introducing Amazon Managed Streaming for Kafka (Amazon MSK) (AN...[NEW LAUNCH!] Introducing Amazon Managed Streaming for Kafka (Amazon MSK) (AN...
[NEW LAUNCH!] Introducing Amazon Managed Streaming for Kafka (Amazon MSK) (AN...
Amazon Web Services
 
Neptune Performance Tuning: Get the Best out of Amazon Neptune (DAT360) - AWS...
Neptune Performance Tuning: Get the Best out of Amazon Neptune (DAT360) - AWS...Neptune Performance Tuning: Get the Best out of Amazon Neptune (DAT360) - AWS...
Neptune Performance Tuning: Get the Best out of Amazon Neptune (DAT360) - AWS...
Amazon Web Services
 

Semelhante a Practical Memory Tuning for PostgreSQL (20)

Deep Dive on Amazon Aurora with PostgreSQL Compatibility (DAT305-R1) - AWS re...
Deep Dive on Amazon Aurora with PostgreSQL Compatibility (DAT305-R1) - AWS re...Deep Dive on Amazon Aurora with PostgreSQL Compatibility (DAT305-R1) - AWS re...
Deep Dive on Amazon Aurora with PostgreSQL Compatibility (DAT305-R1) - AWS re...
 
Speed up your Machine Learning workflows with build-in algorithms
Speed up your Machine Learning workflows with build-in algorithmsSpeed up your Machine Learning workflows with build-in algorithms
Speed up your Machine Learning workflows with build-in algorithms
 
Speed up your Machine Learning workflows with built-in algorithms - Tel Aviv ...
Speed up your Machine Learning workflows with built-in algorithms - Tel Aviv ...Speed up your Machine Learning workflows with built-in algorithms - Tel Aviv ...
Speed up your Machine Learning workflows with built-in algorithms - Tel Aviv ...
 
Dat305 Deep Dive on Amazon Aurora PostgreSQL
Dat305 Deep Dive on Amazon Aurora PostgreSQLDat305 Deep Dive on Amazon Aurora PostgreSQL
Dat305 Deep Dive on Amazon Aurora PostgreSQL
 
Migrating Oracle to Aurora PostgreSQL Utilizing AWS Database Migration Servic...
Migrating Oracle to Aurora PostgreSQL Utilizing AWS Database Migration Servic...Migrating Oracle to Aurora PostgreSQL Utilizing AWS Database Migration Servic...
Migrating Oracle to Aurora PostgreSQL Utilizing AWS Database Migration Servic...
 
Amazon DocumentDB - Architecture 및 Best Practice (Level 200) - 발표자: 장동훈, Sr. ...
Amazon DocumentDB - Architecture 및 Best Practice (Level 200) - 발표자: 장동훈, Sr. ...Amazon DocumentDB - Architecture 및 Best Practice (Level 200) - 발표자: 장동훈, Sr. ...
Amazon DocumentDB - Architecture 및 Best Practice (Level 200) - 발표자: 장동훈, Sr. ...
 
Machine Learning with Amazon SageMaker - Algorithms and Frameworks - BDA304 -...
Machine Learning with Amazon SageMaker - Algorithms and Frameworks - BDA304 -...Machine Learning with Amazon SageMaker - Algorithms and Frameworks - BDA304 -...
Machine Learning with Amazon SageMaker - Algorithms and Frameworks - BDA304 -...
 
Build on Amazon Aurora with MySQL Compatibility (DAT348-R4) - AWS re:Invent 2018
Build on Amazon Aurora with MySQL Compatibility (DAT348-R4) - AWS re:Invent 2018Build on Amazon Aurora with MySQL Compatibility (DAT348-R4) - AWS re:Invent 2018
Build on Amazon Aurora with MySQL Compatibility (DAT348-R4) - AWS re:Invent 2018
 
AWS Container services
AWS Container servicesAWS Container services
AWS Container services
 
AWS Startup Day Kyiv: Container services on AWS. Comparing Amazon ECS, AWS Fa...
AWS Startup Day Kyiv: Container services on AWS. Comparing Amazon ECS, AWS Fa...AWS Startup Day Kyiv: Container services on AWS. Comparing Amazon ECS, AWS Fa...
AWS Startup Day Kyiv: Container services on AWS. Comparing Amazon ECS, AWS Fa...
 
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech TalksElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
ElastiCache: Deep Dive Best Practices and Usage Patterns - AWS Online Tech Talks
 
SRV308 Deep Dive on Amazon Aurora
SRV308 Deep Dive on Amazon AuroraSRV308 Deep Dive on Amazon Aurora
SRV308 Deep Dive on Amazon Aurora
 
Amazon Aurora
Amazon AuroraAmazon Aurora
Amazon Aurora
 
Amazon Aurora - Rajeev Chakrabarti
Amazon Aurora - Rajeev ChakrabartiAmazon Aurora - Rajeev Chakrabarti
Amazon Aurora - Rajeev Chakrabarti
 
AWS Lambda Powertools walkthrough.pdf
AWS Lambda Powertools walkthrough.pdfAWS Lambda Powertools walkthrough.pdf
AWS Lambda Powertools walkthrough.pdf
 
How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...
How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...
How Amazon.com Migrates Inventory Management Systems (DAT346) - AWS re:Invent...
 
Full Page Writes in PostgreSQL PGCONFEU 2022
Full Page Writes in PostgreSQL PGCONFEU 2022Full Page Writes in PostgreSQL PGCONFEU 2022
Full Page Writes in PostgreSQL PGCONFEU 2022
 
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
(DAT402) Amazon RDS PostgreSQL:Lessons Learned & New Features
 
[NEW LAUNCH!] Introducing Amazon Managed Streaming for Kafka (Amazon MSK) (AN...
[NEW LAUNCH!] Introducing Amazon Managed Streaming for Kafka (Amazon MSK) (AN...[NEW LAUNCH!] Introducing Amazon Managed Streaming for Kafka (Amazon MSK) (AN...
[NEW LAUNCH!] Introducing Amazon Managed Streaming for Kafka (Amazon MSK) (AN...
 
Neptune Performance Tuning: Get the Best out of Amazon Neptune (DAT360) - AWS...
Neptune Performance Tuning: Get the Best out of Amazon Neptune (DAT360) - AWS...Neptune Performance Tuning: Get the Best out of Amazon Neptune (DAT360) - AWS...
Neptune Performance Tuning: Get the Best out of Amazon Neptune (DAT360) - AWS...
 

Mais de Grant McAlister

re:Invent 2022 DAT316 Build resilient applications using Amazon RDS and Auror...
re:Invent 2022 DAT316 Build resilient applications using Amazon RDS and Auror...re:Invent 2022 DAT316 Build resilient applications using Amazon RDS and Auror...
re:Invent 2022 DAT316 Build resilient applications using Amazon RDS and Auror...
Grant McAlister
 
re:Invent 2020 DAT301 Deep Dive on Amazon Aurora with PostgreSQL Compatibility
re:Invent 2020 DAT301 Deep Dive on Amazon Aurora with PostgreSQL Compatibilityre:Invent 2020 DAT301 Deep Dive on Amazon Aurora with PostgreSQL Compatibility
re:Invent 2020 DAT301 Deep Dive on Amazon Aurora with PostgreSQL Compatibility
Grant McAlister
 
AWS re:Invent 2019 - DAT328 Deep Dive on Amazon Aurora PostgreSQL
AWS re:Invent 2019 - DAT328 Deep Dive on Amazon Aurora PostgreSQLAWS re:Invent 2019 - DAT328 Deep Dive on Amazon Aurora PostgreSQL
AWS re:Invent 2019 - DAT328 Deep Dive on Amazon Aurora PostgreSQL
Grant McAlister
 
HOT Understanding this important update optimization
HOT Understanding this important update optimizationHOT Understanding this important update optimization
HOT Understanding this important update optimization
Grant McAlister
 
DAT402 - Deep Dive on Amazon Aurora PostgreSQL
DAT402 - Deep Dive on Amazon Aurora PostgreSQL DAT402 - Deep Dive on Amazon Aurora PostgreSQL
DAT402 - Deep Dive on Amazon Aurora PostgreSQL
Grant McAlister
 
Deep dive into the Rds PostgreSQL Universe Austin 2017
Deep dive into the Rds PostgreSQL Universe Austin 2017Deep dive into the Rds PostgreSQL Universe Austin 2017
Deep dive into the Rds PostgreSQL Universe Austin 2017
Grant McAlister
 
Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput
Grant McAlister
 
Amazon RDS for PostgreSQL: What's New and Lessons Learned - NY 2017
Amazon RDS for PostgreSQL: What's New and Lessons Learned - NY 2017Amazon RDS for PostgreSQL: What's New and Lessons Learned - NY 2017
Amazon RDS for PostgreSQL: What's New and Lessons Learned - NY 2017
Grant McAlister
 
Amazon RDS for PostgreSQL - Postgres Open 2016 - New Features and Lessons Lea...
Amazon RDS for PostgreSQL - Postgres Open 2016 - New Features and Lessons Lea...Amazon RDS for PostgreSQL - Postgres Open 2016 - New Features and Lessons Lea...
Amazon RDS for PostgreSQL - Postgres Open 2016 - New Features and Lessons Lea...
Grant McAlister
 
Amazon RDS for PostgreSQL - PGConf 2016
Amazon RDS for PostgreSQL - PGConf 2016 Amazon RDS for PostgreSQL - PGConf 2016
Amazon RDS for PostgreSQL - PGConf 2016
Grant McAlister
 

Mais de Grant McAlister (10)

re:Invent 2022 DAT316 Build resilient applications using Amazon RDS and Auror...
re:Invent 2022 DAT316 Build resilient applications using Amazon RDS and Auror...re:Invent 2022 DAT316 Build resilient applications using Amazon RDS and Auror...
re:Invent 2022 DAT316 Build resilient applications using Amazon RDS and Auror...
 
re:Invent 2020 DAT301 Deep Dive on Amazon Aurora with PostgreSQL Compatibility
re:Invent 2020 DAT301 Deep Dive on Amazon Aurora with PostgreSQL Compatibilityre:Invent 2020 DAT301 Deep Dive on Amazon Aurora with PostgreSQL Compatibility
re:Invent 2020 DAT301 Deep Dive on Amazon Aurora with PostgreSQL Compatibility
 
AWS re:Invent 2019 - DAT328 Deep Dive on Amazon Aurora PostgreSQL
AWS re:Invent 2019 - DAT328 Deep Dive on Amazon Aurora PostgreSQLAWS re:Invent 2019 - DAT328 Deep Dive on Amazon Aurora PostgreSQL
AWS re:Invent 2019 - DAT328 Deep Dive on Amazon Aurora PostgreSQL
 
HOT Understanding this important update optimization
HOT Understanding this important update optimizationHOT Understanding this important update optimization
HOT Understanding this important update optimization
 
DAT402 - Deep Dive on Amazon Aurora PostgreSQL
DAT402 - Deep Dive on Amazon Aurora PostgreSQL DAT402 - Deep Dive on Amazon Aurora PostgreSQL
DAT402 - Deep Dive on Amazon Aurora PostgreSQL
 
Deep dive into the Rds PostgreSQL Universe Austin 2017
Deep dive into the Rds PostgreSQL Universe Austin 2017Deep dive into the Rds PostgreSQL Universe Austin 2017
Deep dive into the Rds PostgreSQL Universe Austin 2017
 
Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput Tuning PostgreSQL for High Write Throughput
Tuning PostgreSQL for High Write Throughput
 
Amazon RDS for PostgreSQL: What's New and Lessons Learned - NY 2017
Amazon RDS for PostgreSQL: What's New and Lessons Learned - NY 2017Amazon RDS for PostgreSQL: What's New and Lessons Learned - NY 2017
Amazon RDS for PostgreSQL: What's New and Lessons Learned - NY 2017
 
Amazon RDS for PostgreSQL - Postgres Open 2016 - New Features and Lessons Lea...
Amazon RDS for PostgreSQL - Postgres Open 2016 - New Features and Lessons Lea...Amazon RDS for PostgreSQL - Postgres Open 2016 - New Features and Lessons Lea...
Amazon RDS for PostgreSQL - Postgres Open 2016 - New Features and Lessons Lea...
 
Amazon RDS for PostgreSQL - PGConf 2016
Amazon RDS for PostgreSQL - PGConf 2016 Amazon RDS for PostgreSQL - PGConf 2016
Amazon RDS for PostgreSQL - PGConf 2016
 

Último

一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
VALiNTRY360
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
dakas1
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Top 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptxTop 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptx
devvsandy
 

Último (20)

一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfTop Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdf
 
一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理一比一原版(USF毕业证)旧金山大学毕业证如何办理
一比一原版(USF毕业证)旧金山大学毕业证如何办理
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Top 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptxTop 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptx
 

Practical Memory Tuning for PostgreSQL

  • 1. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. PRACTICAL MEMORY TUNING FOR POSTGRESQL Grant McAlister Senior Principal Engineer
  • 2. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Why you should care 0 10,000 20,000 30,000 40,000 50,000 60,000 70,000 5 105 205 305 405 505 605 705 805 905 1005 1105 1205 1305 1405 1505 1605 1705 Transactions Per Second (TPS) Seconds sysbench read only point selects Normal Tuning Less than Optimal Tuning 11X buffers not in memory swap thrashing
  • 3. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. OOM & Swap 3
  • 4. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. What is the Out of Memory (OOM) Killer postgres 1 postgres 2 postgres 3 postgres 4 badness_for_task = total_vm_for_task / (sqrt(cpu_time_in_seconds) * sqrt(sqrt(cpu_time_in_minutes)))
  • 5. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. What is the Out of Memory (OOM) Killer postgres 1 postgres 2 postgres 3 postgres 4 badness_for_task = total_vm_for_task / (sqrt(cpu_time_in_seconds) * sqrt(sqrt(cpu_time_in_minutes)))
  • 6. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Why swap? RAM request 8k
  • 7. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Why swap? RAM request 16k FULL
  • 8. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Why swap? RAM SWAP request 16k
  • 9. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Why swap? RAM SWAP request 16k swap out swap in THRASHING
  • 10. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Overview 6
  • 11. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Memory Overview Operating System shared_buffers postgres processes pagecache 25% Operating System shared_buffers postgres processes pagecache 75%
  • 12. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pagecache File System Cache Storage shared_buffers wal archiving misc temp_buffers
  • 13. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pagecache File System Cache Storage shared_buffers wal archiving misc temp_buffers
  • 14. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pagecache File System Cache Storage shared_buffers wal archiving misc shared_buffers wal archiving misc temp_buffers temp_buffers
  • 15. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Pagecache File System Cache Storage shared_buffers wal archiving misc shared_buffers wal archiving misc temp_buffers temp_buffers shared_buffers misc temp_buffers
  • 16. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Working Set Size - Heat Orders_2023 Orders_2022 Orders_2021 Orders_2020 Orders_2019 Orders_2018 Orders_2017 Orders_2016 800GB 80-100GB hot working set
  • 17. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Inventory_SEA Inventory_LAX Inventory_SFO Inventory_EWR Inventory_SYD Inventory_YYC Inventory_BIO Inventory_SBP Working Set Size - Heat Orders_2023 Orders_2022 Orders_2021 Orders_2020 Orders_2019 Orders_2018 Orders_2017 Orders_2016 800GB 80-100GB hot working set Inventory_SEA Inventory_LAX Inventory_SFO Inventory_EWR Inventory_SYD Inventory_YYC Inventory_BIO Inventory_SBP 800GB 200-400GB hot working set
  • 18. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Working Set Size – Indexes and Data Random heap index
  • 19. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Working Set Size – Indexes and Data Random heap index
  • 20. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Working Set Size – Indexes and Data Random heap index
  • 21. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Working Set Size – Indexes and Data Random heap index
  • 22. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Working Set Size – Indexes and Data right leaning heap index
  • 23. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Working Set Size – Indexes and Data right leaning heap index
  • 24. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Working Set Size – Indexes and Data right leaning heap index
  • 25. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Working Set Size – Indexes and Data right leaning heap index
  • 26. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Shared Buffers 12
  • 27. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Small Cache File System Cache Storage shared_buffers
  • 28. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. shared_buffers comparison 14 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% 0 100,000 200,000 300,000 400,000 500,000 600,000 700,000 800,000 900,000 25% of host memory - 80 tables 25% of host memory - 125 tables 25% of host memory - 250 tables 12.5% of host memory - 250 tables 5% of host memory - 250 tables 1% of host memory - 250 tables Percent of object type in memory Transactions Per Second sysbench - read only point selects TPS Index Tables 60%
  • 29. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. shared_buffers comparison – pg_buffercache Type Usage count 25% of host memory 1% of host memory Index 5 855806 3630 Index 4 707472 2624 Index 3 124292 23 Index 2 22019 1754 Index 1 3799 73303 Index 0 558 71569 Table 5 316 1 Table 4 2764 3 Table 3 33572 105 Table 2 359638 180 Table 1 2933760 76505 Table 0 2606002 76303 15
  • 30. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. shared_buffers comparison – pg_buffercache Type Usage count 25% of host memory 1% of host memory Index 5 855806 3630 Index 4 707472 2624 Index 3 124292 23 Index 2 22019 1754 Index 1 3799 73303 Index 0 558 71569 Table 5 316 1 Table 4 2764 3 Table 3 33572 105 Table 2 359638 180 Table 1 2933760 76505 Table 0 2606002 76303 15
  • 31. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Big Cache File System Cache Storage shared_buffers
  • 32. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Big Cache File System Cache Storage shared_buffers
  • 33. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Big Cache File System Cache Storage
  • 34. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Big Cache File System Cache Storage shared_buffers
  • 35. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Big Cache File System Cache Storage shared_buffers
  • 36. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. HugePages 17
  • 37. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Why HugePages – page mapping 18 PageTables shared_buffers pg 1 pg 2 pg 3 4k 4k size of page table = # of PostgreSQL process X amount of shared buffers accessed 2M
  • 38. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 19 0 10,000 20,000 30,000 40,000 50,000 60,000 70,000 5 30 55 80 105 130 155 180 205 230 255 280 305 330 355 380 405 430 455 480 505 530 555 580 605 630 655 680 705 730 755 780 805 830 855 880 905 930 955 980 1005 1030 1055 1080 1105 1130 1155 1180 1205 1230 1255 1280 1305 1330 1355 1380 1405 1430 1455 1480 1505 1530 1555 1580 1605 1630 1655 1680 1705 1730 1755 1780 Transactions Per Second (TPS) Seconds Sysbench Read Only Point Selects – r6i.8xlarge – 250 tables x 2.5M rows – 160GB 250 Client Hupepage=on 250 Client Hupepage=off
  • 39. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 20 0 10,000 20,000 30,000 40,000 50,000 60,000 70,000 5 30 55 80 105 130 155 180 205 230 255 280 305 330 355 380 405 430 455 480 505 530 555 580 605 630 655 680 705 730 755 780 805 830 855 880 905 930 955 980 1005 1030 1055 1080 1105 1130 1155 1180 1205 1230 1255 1280 1305 1330 1355 1380 1405 1430 1455 1480 1505 1530 1555 1580 1605 1630 1655 1680 1705 1730 1755 1780 Transactions Per Second (TPS) Seconds Sysbench Read Only Point Selects – r6i.8xlarge – 250 tables x 2.5M rows – 160GB 500 Client Hupepage=on 500 Client Hupepage=off
  • 40. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 21 0 10,000 20,000 30,000 40,000 50,000 60,000 70,000 5 30 55 80 105 130 155 180 205 230 255 280 305 330 355 380 405 430 455 480 505 530 555 580 605 630 655 680 705 730 755 780 805 830 855 880 905 930 955 980 1005 1030 1055 1080 1105 1130 1155 1180 1205 1230 1255 1280 1305 1330 1355 1380 1405 1430 1455 1480 1505 1530 1555 1580 1605 1630 1655 1680 1705 1730 1755 1780 Transactions Per Second (TPS) Seconds Sysbench Read Only Point Selects – r6i.8xlarge – 250 tables x 2.5M rows – 160GB 1000 Client Hupepage=on 1000 Client Hupepage=off
  • 41. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Cost of not setting HugePages 22 0% 5% 10% 15% 20% 25% 30% 35% 40% 45% 50% 0 20 40 60 80 100 120 140 250 500 1000 Percent of host memory GB of PageTable number of postgreSQL process sysbench read only - shard_buffer=25% of ram PageTables size (gb) % of host memory
  • 42. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Per Session 23
  • 43. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. temp_buffers shared_buffers temp_buffers File System Cache regular tables temp tables global session local
  • 44. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. SQL Stream logical_decoding_work_mem OLTP DW SQL Stream logical decoding slot wal log DW2 logical decoding slot SQL Stream
  • 45. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Per Session Operation 26
  • 46. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. work_mem postgres=# set work_mem TO '1 GB’; postgres=# explain analyze select mykey::bigint, (random()*10000000000)::bigint as scratch , repeat('X', 1024)::char(1024) filler from generate_series(1,3800000) as mykey order by scratch; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------ - Sort (cost=7219224.79..7228724.79 rows=3800000 width=4116) (actual time=7083.506..8358.093 rows=3800000 loops=1) Sort Key: (((random() * '10000000000'::double precision))::bigint) Sort Method: external merge Disk: 3919000kB -> Function Scan on generate_series mykey (cost=0.00..76000.00 rows=3800000 width=4116) (actual time=194.053..493.117 rows=3800000 loops=1) Planning Time: 0.049 ms Execution Time: 9117.344 ms (6 rows) ~3.8GB
  • 47. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 28 0 1 2 3 4 5 6 7 8 9 10 1 6 11 16 21 26 31 36 41 46 51 56 GB RAM Seconds work_mem - sorting 1GB work_mem 3.8GB query
  • 48. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. work_mem postgres=# set work_mem TO '4 GB’; postgres=# explain analyze select mykey::bigint, (random()*10000000000)::bigint as scratch , repeat('X', 1024)::char(1024) filler from generate_series(1,3800000) as mykey order by scratch; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------ - Sort (cost=7219224.79..7228724.79 rows=3800000 width=4116) (actual time=2766.682..3408.706 rows=3800000 loops=1) Sort Key: (((random() * '10000000000'::double precision))::bigint) Sort Method: quicksort Memory: 4128025kB -> Function Scan on generate_series mykey (cost=0.00..76000.00 rows=3800000 width=4116) (actual time=194.365..506.965 rows=3800000 loops=1) Planning Time: 0.047 ms Execution Time: 3825.965 ms (6 rows) ~3.8GB
  • 49. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 30 0 1 2 3 4 5 6 7 8 9 10 1 6 11 16 21 26 31 36 41 46 51 56 GB RAM Seconds work_mem - sorting 4GB work_mem - 3.8GB query 1GB work_mem 3.8GB query
  • 50. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. work_mem postgres=# set work_mem TO '4 GB’; explain analyze select s1.filler, s2.filler,s1.mykey, s2.mykey, s1.scratch, s2.scratch from (select mykey::bigint, (random()*1000000000)::bigint as scratch , repeat('X', 1024)::char(1024) filler from generate_series(1,3800000) as mykey order by scratch) s1, (select mykey::bigint, (random()*10000000000)::bigint as scratch , repeat('X', 1024)::char(1024) filler from generate_series(1,3800000) as mykey order by scratch) s2 where s1.scratch=s2.scratch order by s1.mykey; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------ --------------------- Sort (cost=523467712452.33..523648212452.33 rows=72200000000 width=8232) (actual time=6851.977..6852.172 rows=1494 loops=1) Sort Key: ((mykey.mykey)::bigint) Sort Method: quicksort Memory: 3153kB -> Merge Join (cost=14438449.59..1097542949.59 rows=72200000000 width=8232) (actual time=5558.904..6850.847 rows=1494 loops=1) Merge Cond: ((((random() * '1000000000'::double precision))::bigint) = (((random() * '10000000000'::double precision))::bigint)) -> Sort (cost=7219224.79..7228724.79 rows=3800000 width=4116) (actual time=2785.745..3524.489 rows=3800000 loops=1) Sort Key: (((random() * '1000000000'::double precision))::bigint) Sort Method: quicksort Memory: 4128025kB -> Function Scan on generate_series mykey (cost=0.00..76000.00 rows=3800000 width=4116) (actual time=194.222..515.986 rows=3800000 loops=1) -> Materialize (cost=7219224.79..7276224.79 rows=3800000 width=4116) (actual time=2772.383..2961.007 rows=380357 loops=1) -> Sort (cost=7219224.79..7228724.79 rows=3800000 width=4116) (actual time=2772.377..2867.394 rows=380353 loops=1) Sort Key: (((random() * '10000000000'::double precision))::bigint) Sort Method: quicksort Memory: 4128025kB -> Function Scan on generate_series mykey_1 (cost=0.00..76000.00 rows=3800000 width=4116) (actual time=198.688..511.083 rows=3800000 loops=1) Planning Time: 0.098 ms Execution Time: 7511.377 ms ~3.8GB
  • 51. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 32 0 1 2 3 4 5 6 7 8 9 10 1 6 11 16 21 26 31 36 41 46 51 56 GB RAM Seconds work_mem - sorting 4GB work_mem - 7.6GB+ query 4GB work_mem - 3.8GB query 1GB work_mem 3.8GB query
  • 52. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. work_mem postgres=# set work_mem TO '4 GB’; postgres=# explain analyze select s1.filler, s2.filler,s1.mykey, s2.mykey, s1.scratch, s2.scratch from (select mykey::bigint, (random()*1000000000)::bigint as scratch , repeat('X', 1024)::char(1024) filler from generate_series(1,18800000) as mykey order by scratch) s1, (select mykey::bigint, (random()*10000000000)::bigint as scratch , repeat('X', 1024)::char(1024) filler from generate_series(1,3800000) as mykey order by scratch) s2 where s1.scratch=s2.scratch order by s1.mykey; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------- Sort (cost=3853846009559.71..3854739009559.71 rows=357200000000 width=8232) (actual time=52689.953..52690.952 rows=7184 loops=1) Sort Key: ((mykey_1.mykey)::bigint) Sort Method: quicksort Memory: 15122kB -> Merge Join (cost=43152211.85..5401444211.85 rows=357200000000 width=8232) (actual time=42991.198..52679.295 rows=7184 loops=1) Merge Cond: ((((random() * '10000000000'::double precision))::bigint) = (((random() * '1000000000'::double precision))::bigint)) -> Sort (cost=7219224.79..7228724.79 rows=3800000 width=4116) (actual time=2771.496..2877.777 rows=380382 loops=1) Sort Key: (((random() * '10000000000'::double precision))::bigint) Sort Method: quicksort Memory: 4128025kB -> Function Scan on generate_series mykey (cost=0.00..76000.00 rows=3800000 width=4116) (actual time=194.404..516.400 rows=3800000 loops=1) -> Materialize (cost=35932987.06..36214987.06 rows=18800000 width=4116) (actual time=40218.833..48614.865 rows=18800001 loops=1) -> Sort (cost=35932987.06..35979987.06 rows=18800000 width=4116) (actual time=40218.824..46815.209 rows=18800000 loops=1) Sort Key: (((random() * '1000000000'::double precision))::bigint) Sort Method: external merge Disk: 19388680kB -> Function Scan on generate_series mykey_1 (cost=0.00..376000.00 rows=18800000 width=4116) (actual time=960.638..2593.178 rows=18800000 loops=1) Planning Time: 0.102 ms Execution Time: 55724.412 ms ~3.8GB ~18.8GB
  • 53. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 34 0 1 2 3 4 5 6 7 8 9 10 1 6 11 16 21 26 31 36 41 46 51 56 GB RAM Seconds work_mem - sorting 4GB work_mem - 18.8GB+ query 4GB work_mem - 7.6GB+ query 4GB work_mem - 3.8GB query 1GB work_mem 3.8GB query
  • 54. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. hash_mem_multiplier postgres=# show hash_mem_multiplier; hash_mem_multiplier --------------------- 2 postgres=# set work_mem=‘4 GB'; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- Hash Join (cost=2083766.00..5865195158.01 rows=167200000000 width=8232) (actual time=4360.794..16414.748 rows=3344 loops=1) Hash Cond: (s1.scratch = s2.scratch) -> Subquery Scan on s1 (cost=0.00..264000.00 rows=8800000 width=4116) (actual time=374.153..1692.160 rows=8800000 loops=1) -> Function Scan on generate_series mykey (cost=0.00..176000.00 rows=8800000 width=4116) (actual time=374.152..1161.469 rows=8800000 loops=1) -> Hash (cost=114000.00..114000.00 rows=3800000 width=4116) (actual time=3982.004..3982.006 rows=3800000 loops=1) Buckets: 2097152 Batches: 2 Memory Usage: 2020102kB -> Subquery Scan on s2 (cost=0.00..114000.00 rows=3800000 width=4116) (actual time=186.934..742.574 rows=3800000 loops=1) -> Function Scan on generate_series mykey_1 (cost=0.00..76000.00 rows=3800000 width=4116) (actual time=186.932..515.290 rows=3800000 loops=1) Planning Time: 0.090 ms Execution Time: 16655.195 ms (10 rows) postgres=# set work_mem='1 GB'; SET QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------- Hash Join (cost=2083766.00..5865195158.01 rows=167200000000 width=8232) (actual time=5099.725..23063.116 rows=3575 loops=1) Hash Cond: (s1.scratch = s2.scratch) -> Subquery Scan on s1 (cost=0.00..264000.00 rows=8800000 width=4116) (actual time=376.939..1651.354 rows=8800000 loops=1) -> Function Scan on generate_series mykey (cost=0.00..176000.00 rows=8800000 width=4116) (actual time=376.937..1119.345 rows=8800000 loops=1) -> Hash (cost=114000.00..114000.00 rows=3800000 width=4116) (actual time=4714.890..4714.891 rows=3800000 loops=1) Buckets: 524288 Batches: 8 Memory Usage: 505086kB -> Subquery Scan on s2 (cost=0.00..114000.00 rows=3800000 width=4116) (actual time=181.422..740.776 rows=3800000 loops=1) -> Function Scan on generate_series mykey_1 (cost=0.00..76000.00 rows=3800000 width=4116) (actual time=181.420..512.871 rows=3800000 loops=1) Planning Time: 0.089 ms Execution Time: 23186.765 ms ~2.6GB – 16.6 seconds ~1.2GB – 23.1 seconds
  • 55. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Per Session Item 36
  • 56. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. prepared statements PREPARE sbtestplan (int) AS SELECT * FROM sbtest1 WHERE id=$1 ; EXECUTE sbtestplan(1); sbtest=# SELECT name, ident, level, total_bytes FROM pg_backend_memory_contexts where name ='CachedPlanSource'; name | ident | level | total_bytes ------------------+-----------------------------------------+-------+------------- CachedPlanSource | PREPARE sbtestplan3 (int) AS +| 2 | 4096 | SELECT * FROM sbtest3 WHERE id=$1 ; | | CachedPlanSource | PREPARE sbtestplan2 (int) AS +| 2 | 4096 | SELECT * FROM sbtest2 WHERE id=$1 ; | | CachedPlanSource | PREPARE sbtestplan (int) AS +| 2 | 4096 | SELECT * FROM sbtest1 WHERE id=$1 ; | |
  • 57. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. prepared statements – 10 Million 38 0 20 40 60 80 100 1 7 13 19 25 31 37 43 49 55 61 67 73 79 85 91 97 103 109 115 121 127 133 139 145 151 157 163 169 175 181 187 193 199 205 211 217 223 229 235 241 247 253 259 265 271 277 283 289 295 301 307 313 319 325 331 337 343 349 355 361 GB Used Seconds 10 million prepared statements - 1 client
  • 58. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Maintenance 39
  • 59. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. maintenance_work_mem – Index builds sbtest=# set maintenance_work_mem = '1 GB'; ^ sbtest=# create index foo on sbtest1 (id,c,pad,k desc) ; CREATE INDEX Time: 45803.577 ms (00:45.804) sbtest=# set maintenance_work_mem = '2 GB'; sbtest=# create index foo on sbtest1 (id,c,pad,k desc) ; CREATE INDEX Time: 45904.760 ms (00:45.905) sbtest=# set maintenance_work_mem = '4 GB'; sbtest=# create index foo on sbtest1 (id,c,pad,k desc) ; CREATE INDEX Time: 46081.414 ms (00:46.081) ~1GB ~2GB ~3GB
  • 60. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. maintenance_work_mem – how vacuum works heap index index vacuum scan heap
  • 61. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. maintenance_work_mem – how vacuum works heap index index vacuum maintenance_work_mem tid to clean scan heap
  • 62. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. maintenance_work_mem – how vacuum works heap index index vacuum maintenance_work_mem tid to clean scan heap scan indexes
  • 63. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. maintenance_work_mem - vacuum sbtest=# set maintenance_work_mem='100 MB'; sbtest=# vacuum (verbose) sbtest1; INFO: vacuuming "sbtest.public.sbtest1" INFO: launched 1 parallel vacuum worker for index vacuuming (planned: 1) INFO: launched 1 parallel vacuum worker for index vacuuming (planned: 1) INFO: finished vacuuming "sbtest.public.sbtest1": index scans: 2 pages: 0 removed, 13921343 remain, 13921343 scanned (100.00% of total) tuples: 11014287 removed, 500000000 remain, 0 are dead but not yet removable removable cutoff: 74587243, which was 0 XIDs old when operation ended index scan needed: 11236460 pages from table (80.71% of total) had 18915133 dead item identifiers removed index "sbtest1_pkey": pages: 1370933 in total, 0 newly deleted, 0 currently deleted, 0 reusable index "k_1": pages: 1202589 in total, 0 newly deleted, 0 currently deleted, 0 reusable avg read rate: 102.408 MB/s, avg write rate: 99.348 MB/s buffer usage: 16918231 hits, 24908382 misses, 24164093 dirtied WAL usage: 48871286 records, 26289264 full page images, 210588376068 bytes system usage: CPU: user: 184.21 s, system: 275.86 s, elapsed: 1900.21 s VACUUM
  • 64. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. maintenance_work_mem - vacuum sbtest=# set maintenance_work_mem='1 GB’; sbtest=# vacuum (verbose) sbtest1; INFO: vacuuming "sbtest.public.sbtest1" INFO: launched 1 parallel vacuum worker for index vacuuming (planned: 1) INFO: finished vacuuming "sbtest.public.sbtest1": index scans: 1 pages: 0 removed, 13921343 remain, 13921343 scanned (100.00% of total) tuples: 10990324 removed, 500000000 remain, 0 are dead but not yet removable removable cutoff: 103987274, which was 0 XIDs old when operation ended new relfrozenxid: 53987274, which is 11901571 XIDs ahead of previous value index scan needed: 10126301 pages from table (72.74% of total) had 16347414 dead item identifiers removed index "sbtest1_pkey": pages: 1370933 in total, 0 newly deleted, 0 currently deleted, 0 reusable index "k_1": pages: 1202589 in total, 0 newly deleted, 0 currently deleted, 0 reusable avg read rate: 90.361 MB/s, avg write rate: 101.013 MB/s buffer usage: 16700415 hits, 22645066 misses, 25314603 dirtied WAL usage: 63975507 records, 26568355 full page images, 219969619018 bytes system usage: CPU: user: 195.27 s, system: 265.41 s, elapsed: 1957.86 s VACUUM
  • 65. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. maintenance_work_mem - vacuum parallel sbtest=# set maintenance_work_mem='1 GB’; sbtest=# vacuum (verbose) sbtest1; INFO: vacuuming "sbtest.public.sbtest1" INFO: launched 2 parallel vacuum workers for index vacuuming (planned: 2)
  • 66. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. autovacuum_work_mem max mem = autovacuum_work_mem X autovacuum_max_workers
  • 67. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Why you should care 0 10,000 20,000 30,000 40,000 50,000 60,000 70,000 5 105 205 305 405 505 605 705 805 905 1005 1105 1205 1305 1405 1505 1605 1705 Transactions Per Second (TPS) Seconds sysbench read only point selects Normal Tuning Less than Optimal Tuning 11X buffers not in memory swap thrashing
  • 68. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Thank you! © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Grant McAlister

Notas do Editor

  1. More flexibility but more overhead and problems finding freeable blocks
  2. Cold cache on restart PostgreSQL uses it for a lot of items, prefetch, lots of different buffering, temporary tables buffering, etc
  3. Also note that hugepages are not swapable so less likely to get into thrashing
  4. You can also have parallel which could make this a lot larger
  5. Other objects can also use a lot of ram per session, older sessions need to be pruned
  6. Try to keep the most important items in memory Minimize swapping (i.e. avoid thrashing) Avoid OOM (Out of Memory)