---
title: "Postgresql vacuum analyze"
author: "jXee"
date: "2018-05-15T10:07:53Z"
tags: []
categories: ["数据库"]
slug: "postgresql-vacuum-analyze"
draft: false
lastmod: "2018-05-15T10:10:35Z"
id: 2422756
url: "https://jxee.iteye.com/blog/2422756"
---

There is no VACUUM statement in the SQL standard.

Postgresql has command VACUUM to cleanup dead tuples in database tables. After deletion, a record still stays in the table, VACUUM makes sure the space is reclaimed and made available for re-use.

Option ANALYZE would "Updates statistics used by the planner to determine the most efficient way to execute a query".

So the common usage of it would be running command "VACUUM ANALYZE" after done a bulk deletion and/or update. This would vacuum the whole database. You can append a specific table name after the command to just vacuum the table: "VACUUM ANALYZE your-table-name", like "vacuum analyze fscore.geofence_event;"

Postgres has an Autovacuum Daemon which would automatically vacuum+analyze the database. This setting is turned on by default and you can check it on by running this command: "show autovacuum;"

AWS RDS of postgres also has it on by default.