postgres Autovacuum not working in all cases?

Questions and answers regarding general SQL and backend databases

postgres Autovacuum not working in all cases?

Postby Bernd.N » Sun Nov 15, 2015 11:34 pm

We store the metadata of our fields in a table named "fields", which during the update process of our solution, is copied as CSV file to the clients.
There, a "DELETE FROM fields" is running first, and then we import the CSV again so that our customers have again the current state of that metadata table.
Autovacuum is switched on at their postgres server.

The table statistic tells its size is 656 KB on our site, but 35 MB at the customer.
Although the "DELETE FROM fields" should always delete everything first, and Autovacuum did run two days ago.

I could try TRUNCATE instead, however as that is not standard SQL, I would rather like to know the root cause for the above.
By the way, when I backup the customer's database, that is then just 4 MB large, so the "real" size of that table is for sure not 35 MB.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: postgres Autovacuum not working in all cases?

Postby Bernd.N » Mon Nov 16, 2015 4:37 pm

I found now that when I explicitly run a "VACUUM FULL" (with right click on the table in pgAdmin and then Maintenance, I guess (german=Wartung)), then it will reclaim the full table space.
Otherwise postgres thinks the 35 MB will be needed anyway in future as there were so many subsequent INSERTs (from importing the CSVs during each updating process), while we know that this is just an app-table that should only be replaced.

Looks like using TRUNCATE is the better option in those cases, we will try that.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 544
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany


Return to SQL Databases

Who is online

Users browsing this forum: No registered users and 3 guests

cron