summaryrefslogtreecommitdiffstats
path: root/health/guides/postgres/postgres_table_last_autoanalyze_time.md
diff options
context:
space:
mode:
Diffstat (limited to 'health/guides/postgres/postgres_table_last_autoanalyze_time.md')
-rw-r--r--health/guides/postgres/postgres_table_last_autoanalyze_time.md41
1 files changed, 41 insertions, 0 deletions
diff --git a/health/guides/postgres/postgres_table_last_autoanalyze_time.md b/health/guides/postgres/postgres_table_last_autoanalyze_time.md
new file mode 100644
index 000000000..1a7a3d79b
--- /dev/null
+++ b/health/guides/postgres/postgres_table_last_autoanalyze_time.md
@@ -0,0 +1,41 @@
+### Understand the alert
+
+This alert is triggered when the time elapsed since a PostgreSQL table was last analyzed by the AutoVacuum daemon exceeds one week. AutoVacuum is responsible for recovering storage, optimizing the database, and updating statistics used by the PostgreSQL query planner. If you receive this alert, it indicates that one or more of your PostgreSQL tables have not been analyzed recently which may impact performance.
+
+### What is PostgreSQL table autoanalyze?
+
+In PostgreSQL, table autoanalyze is a process carried out by the AutoVacuum daemon. This process analyzes the table contents and gathers statistics for the query planner to help it make better decisions about optimizing your queries. Regular autoanalyze is crucial for maintaining good performance in your PostgreSQL database.
+
+### Troubleshoot the alert
+
+1. Check the current AutoVacuum settings: To verify if AutoVacuum is enabled and configured correctly in your PostgreSQL database, run the following SQL command:
+
+ ```sql
+ SHOW autovacuum;
+ ```
+
+ If it returns `on`, AutoVacuum is enabled. Otherwise, enable AutoVacuum by modifying the `postgresql.conf` file, and set `autovacuum = on`. Then, restart the PostgreSQL service.
+
+2. Analyze the table manually: If AutoVacuum is enabled but the table has not been analyzed recently, you can manually analyze the table by running the following SQL command:
+
+ ```sql
+ ANALYZE [VERBOSE] [schema_name.]table_name;
+ ```
+
+ Replace `[schema_name.]table_name` with the appropriate schema and table name. The optional `VERBOSE` keyword provides detailed information about the analyze process.
+
+3. Investigate any errors during autoanalyze: If AutoVacuum is enabled and running but you still receive this alert, check the PostgreSQL log files for any errors or issues related to the AutoVacuum process. Address any issues discovered in the logs.
+
+4. Monitor AutoVacuum activity: To get an overview of AutoVacuum activity, you can monitor the `pg_stat_progress_vacuum` view. Run the following SQL command to inspect the view:
+
+ ```sql
+ SELECT * FROM pg_stat_progress_vacuum;
+ ```
+
+ Analyze the results to determine if there are any inefficiencies or issues with the AutoVacuum settings.
+
+### Useful resources
+
+1. [PostgreSQL: AutoVacuum](https://www.postgresql.org/docs/current/routine-vacuuming.html)
+2. [PostgreSQL: Analyzing a Table](https://www.postgresql.org/docs/current/sql-analyze.html)
+3. [PostgreSQL: Monitoring AutoVacuum Progress](https://www.postgresql.org/docs/current/progress-reporting.html#VACUUM-PART) \ No newline at end of file