Skip to content

Commit 308072c

Browse files
committed
final edit sweep plus adding table
1 parent 20e685d commit 308072c

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

articles/postgresql/flexible-server/how-to-autovacuum-tuning.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,14 @@ PostgreSQL uses a process called autovacuum to automatically clean up dead tuple
2424

2525
Autovacuum reads pages looking for dead tuples, and if none are found, autovacuum discard the page. When autovacuum finds dead tuples, it removes them. The cost is based on:
2626

27-
`vacuum_cost_page_hit`
28-
Cost of reading a page that is already in shared buffers and does not need a disk read. The default value is set to 1.
27+
- `vacuum_cost_page_hit`: Cost of reading a page that is already in shared buffers and does not need a disk read. The default value is set to 1.
28+
- `vacuum_cost_page_miss`: Cost of fetching a page that is not in shared buffers. The default value is set to 10.
29+
- `vacuum_cost_page_dirty`: Cost of writing to a page when dead tuples are found in it. The default value is set to 20.
2930

30-
`vacuum_cost_page_miss`
31-
Cost of fetching a page that is not in shared buffers. The default value is set to 10.
31+
The amount of work autovacuum does depends on two parameters:
3232

33-
`vacuum_cost_page_dirty`
34-
Cost of writing to a page when dead tuples are found in it. The default value is set to 20.
35-
36-
The amount of work autovacuum does depends on two parameters:
37-
38-
`autovacuum_vacuum_cost_delay`
39-
`autovacuum_vacuum_cost_limit`
40-
41-
`autovacuum_vacuum_cost_limit` is the amount of work autovacuum does in one go and every time the cleanup is done autovacuum sleeps for `autovacuum_vacuum_cost_delay` number of milliseconds.
33+
- `autovacuum_vacuum_cost_limit` is the amount of work autovacuum does in one go and once the cleanup process is done, the amount of time autovacuum is asleep.
34+
- `autovacuum_vacuum_cost_delay` number of milliseconds.
4235

4336

4437
In Postgres versions 9.6, 10 and 11 the default for `autovacuum_vacuum_cost_limit` is 200 and `autovacuum_vacuum_cost_delay` is 20 milliseconds.
@@ -73,7 +66,7 @@ The following columns help determine if autovacuum is catching up to table activ
7366

7467
## When Does PostgreSQL Trigger Autovacuum
7568

76-
An autovacuum action (either *ANALYZE* or *VACUUM*) triggers when the number of dead tuples exceeds a particular number that is dependent on two factors: the total count of rows in a table, plus a fixed threshold. *ANALYZE*, by default, triggers when 10% of the table plus 50 rows changes, while *VACUUM* triggers when 20% of the table plus 50 rows changes. Since the *VACUUM* threshold is twice as high as the *ANALYZE* threshold, *ANALYZE gets triggered much earlier than *VACUUM*.
69+
An autovacuum action (either *ANALYZE* or *VACUUM*) triggers when the number of dead tuples exceeds a particular number that is dependent on two factors: the total count of rows in a table, plus a fixed threshold. *ANALYZE*, by default, triggers when 10% of the table plus 50 rows changes, while *VACUUM* triggers when 20% of the table plus 50 rows changes. Since the *VACUUM* threshold is twice as high as the *ANALYZE* threshold, *ANALYZE* gets triggered much earlier than *VACUUM*.
7770

7871
The exact equations for each action are:
7972

@@ -138,29 +131,38 @@ Review the possible common problems with the autovacuum process.
138131
The autovacuum process estimates the cost of every I/O operation, accumulates a total for each operation it performs and pauses once the upper limit of the cost is reached. `autovacuum_vacuum_cost_delay` and `autovacuum_vacuum_cost_limit` are the two server parameters that are used in the process.
139132

140133

141-
By default, `autovacuum_vacuum_cost_limit` is set to –1 meaning autovacuum cost limit would be same value as the parameter – `vacuum_cost_limit` that defaults to 200.
134+
By default, `autovacuum_vacuum_cost_limit` is set to –1, meaning autovacuum cost limit is the same value as the parameter `vacuum_cost_limit`, which defaults to 200. `vacuum_cost_limit` is the cost of a manual vacuum.
142135

143-
`vacuum_cost_limit` is the cost of manual vacuum. If `autovacuum_vacuum_cost_limit` is set to -1 then autovacuum would use `vacuum_cost_limit` parameter but if `autovacuum_vacuum_cost_limit` itself is set greater than -1 then `autovacuum_vacuum_cost_limit` parameter is considered.
136+
If `autovacuum_vacuum_cost_limit` is set to `-1` then autovacuum uses the `vacuum_cost_limit` parameter, but if `autovacuum_vacuum_cost_limit` itself is set to greater than `-1` then `autovacuum_vacuum_cost_limit` parameter is considered.
144137

145138
In case the autovacuum is not keeping up, the following parameters may be changed:
146139

140+
141+
142+
|Parameter |Description |
143+
|---------|---------|
144+
|`autovacuum_vacuum_scale_factor`| Default: `0.2`, range: `0.05 - 0.1`. The scale factor is workload-specific and should be set depending on the amount of data in the tables. Before changing the value, investigate the workload and individual table volumes. |
145+
|`autovacuum_vacuum_cost_limit`|Default: `200`. Cost limit may be increased. CPU and I/O utilization on the database should be monitored before and after making changes. |
146+
|`autovacuum_vacuum_cost_delay` | **Postgres Versions 9.6,10,11** - Default: `20 ms`. The parameter may be decreased to `2-10 ms`. </br> **Postgres Versions 12 and above** - Default: `2 ms`. |
147+
148+
147149
##### `autovacuum_vacuum_scale_factor`
148150

149-
Default: 0.2, range 0.05 - 0.1. The scale factor is workload-specific and should be set depending on the amount of data in the tables. Before changing the value, the workload and individual table volumes need to be investigated.
151+
Default: `0.2`, range: `0.05 - 0.1`. The scale factor is workload-specific and should be set depending on the amount of data in the tables. Before changing the value, investigate the workload and individual table volumes.
150152

151153
##### `autovacuum_vacuum_cost_limit`
152154

153-
Default: 200. Cost limit may be increased. CPU and I/O utilization on the database should be monitored before and after making changes.
155+
Default: `200`. Cost limit may be increased. CPU and I/O utilization on the database should be monitored before and after making changes.
154156

155157
##### `autovacuum_vacuum_cost_delay`
156158

157159
###### Postgres Versions 9.6,10,11
158160

159-
Default: 20 ms. The parameter may be decreased to 2-10 ms.
161+
Default: `20 ms`. The parameter may be decreased to `2-10 ms`.
160162

161163
###### Postgres Versions 12 and above
162164

163-
Default: 2 ms.
165+
Default: `2 ms`.
164166

165167
> [!NOTE]
166168
> The `autovacuum_vacuum_cost_limit` value is distributed proportionally among the running autovacuum workers, so that if there is more than one, the sum of the limits for each worker does not exceed the value of the `autovacuum_vacuum_cost_limit` parameter
@@ -172,7 +174,7 @@ Continuously running autovacuum may affect CPU and IO utilization on the server.
172174

173175
##### `maintenance_work_mem`
174176

175-
Autovacuum daemon uses `autovacuum_work_mem` that is by default set to -1 meaning `autovacuum_work_mem` would have the same value as the parameter `maintenance_work_mem`. This document assumes `autovacuum_work_mem` is set to -1 and `maintenance_work_mem` is used by the autovacuum daemon.
177+
Autovacuum daemon uses `autovacuum_work_mem` that is by default set to `-1` meaning `autovacuum_work_mem` would have the same value as the parameter `maintenance_work_mem`. This document assumes `autovacuum_work_mem` is set to `-1` and `maintenance_work_mem` is used by the autovacuum daemon.
176178

177179
If `maintenance_work_mem` is low, it may be increased to up to 2 GB on Flexible Server. A general rule of thumb is to allocate 50 MB to `maintenance_work_mem` for every 1 GB of RAM. 
178180

@@ -222,8 +224,8 @@ However, if we have changed table level `autovacuum_vacuum_cost_delay` or 
222224
When a database runs into transaction ID wraparound protection, an error message like the following can be observed:
223225

224226
```
225-
<i>database is not accepting commands to avoid wraparound data loss in database ‘xx’
226-
Stop the postmaster and vacuum that database in single-user mode. </i>
227+
Database is not accepting commands to avoid wraparound data loss in database ‘xx’
228+
Stop the postmaster and vacuum that database in single-user mode.
227229
```
228230

229231
> [!NOTE]

articles/postgresql/flexible-server/how-to-high-cpu-utilization.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.date: 7/28/2022
1212
# Troubleshoot high CPU utilization in Azure Database for PostgreSQL - Flexible Server
1313

1414

15-
This article shows you how to quickly identify the root cause of high CPU utilization, and possible remedial actions to control CPU utilization when using Azure Database for PostgreSQL - Flexible Server.
15+
This article shows you how to quickly identify the root cause of high CPU utilization, and possible remedial actions to control CPU utilization when using [Azure Database for PostgreSQL - Flexible Server](overview.md).
1616

1717

1818
In this article, you will learn:
@@ -181,7 +181,8 @@ Keeping table statistics up to date helps improve query performance. Monitor whe
181181
The following query helps to identify the tables that need vacuuming:
182182

183183
```postgresql
184-
select schemaname,relname,n_dead_tup,n_live_tup,last_vacuum,last_analyze,last_autovacuum,last_autoanalyze from pg_stat_all_tables where n_live_tup > 0;  
184+
select schemaname,relname,n_dead_tup,n_live_tup,last_vacuum,last_analyze,last_autovacuum,last_autoanalyze
185+
from pg_stat_all_tables where n_live_tup > 0;  
185186
```
186187

187188
`last_autovacuum` and `last_autoanalyze` columns give the date and time when the table was last autovacuumed or analyzed. If the tables are not being vacuumed regularly, take steps to tune autovacuum. For more information about autovacuum troubleshooting and tuning, see [Autovacuum Troubleshooting](./how-to-autovacuum-tuning.md).

articles/postgresql/flexible-server/how-to-high-memory-utilization.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ ms.date: 7/28/2022
1111

1212
# High Memory Utilization in Azure Database for PostgreSQL - Flexible Server
1313

14-
This article introduces common scenarios and root causes that might lead to high memory utilization in Azure Database for PostgreSQL - Flexible Server.
14+
This article introduces common scenarios and root causes that might lead to high memory utilization in [Azure Database for PostgreSQL - Flexible Server](overview.md).
1515

1616
In this article, you will learn:
1717

18-
- Tools to identify high memory utilization.
19-
- Reasons for high memory & remedial actions.
18+
- Tools to identify high memory utilization.
19+
- Reasons for high memory & remedial actions.
2020

2121

2222
## Tools to Identify High Memory Utilization

0 commit comments

Comments
 (0)