You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/postgresql/flexible-server/how-to-autovacuum-tuning.md
+25-23Lines changed: 25 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,21 +24,14 @@ PostgreSQL uses a process called autovacuum to automatically clean up dead tuple
24
24
25
25
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:
26
26
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.
29
30
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:
32
32
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.
42
35
43
36
44
37
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
73
66
74
67
## When Does PostgreSQL Trigger Autovacuum
75
68
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*.
77
70
78
71
The exact equations for each action are:
79
72
@@ -138,29 +131,38 @@ Review the possible common problems with the autovacuum process.
138
131
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.
139
132
140
133
141
-
By default, `autovacuum_vacuum_cost_limit` is set to –1meaning 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.
142
135
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` parameterbut 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.
144
137
145
138
In case the autovacuum is not keeping up, the following parameters may be changed:
146
139
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
+
147
149
##### `autovacuum_vacuum_scale_factor`
148
150
149
-
Default: 0.2, range0.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.
150
152
151
153
##### `autovacuum_vacuum_cost_limit`
152
154
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.
154
156
155
157
##### `autovacuum_vacuum_cost_delay`
156
158
157
159
###### Postgres Versions 9.6,10,11
158
160
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`.
160
162
161
163
###### Postgres Versions 12 and above
162
164
163
-
Default: 2 ms.
165
+
Default: `2 ms`.
164
166
165
167
> [!NOTE]
166
168
> 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.
172
174
173
175
##### `maintenance_work_mem`
174
176
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.
176
178
177
179
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.
178
180
@@ -222,8 +224,8 @@ However, if we have changed table level `autovacuum_vacuum_cost_delay` or
222
224
When a database runs into transaction ID wraparound protection, an error message like the following can be observed:
223
225
224
226
```
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.
Copy file name to clipboardExpand all lines: articles/postgresql/flexible-server/how-to-high-cpu-utilization.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ ms.date: 7/28/2022
12
12
# Troubleshoot high CPU utilization in Azure Database for PostgreSQL - Flexible Server
13
13
14
14
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).
16
16
17
17
18
18
In this article, you will learn:
@@ -181,7 +181,8 @@ Keeping table statistics up to date helps improve query performance. Monitor whe
181
181
The following query helps to identify the tables that need vacuuming:
182
182
183
183
```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;
`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).
Copy file name to clipboardExpand all lines: articles/postgresql/flexible-server/how-to-high-memory-utilization.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,12 +11,12 @@ ms.date: 7/28/2022
11
11
12
12
# High Memory Utilization in Azure Database for PostgreSQL - Flexible Server
13
13
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).
0 commit comments