This question has been flagged
7 Replies
11856 Views

Hi everyone,

My odoo postgresql database size starts to grow in a fast way. today it is up to 12Gb.
Is it normal or there are some log files i have to remove or clear from time to time and which keep my database so huge.
I'm using Odoo under Ubuntu.

Avatar
Discard
Best Answer

Hi Thicham,


I had a similar issue some months ago. The problem was located in an module that stored big binary files in the database.

I would suggest that you analyse your database to find out you which tables store a big amount of data. To do this, you can run follow query on you database:

SELECT nspname || '.' || relname AS "relation",    pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size"  FROM pg_class C  LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)  WHERE nspname NOT IN ('pg_catalog', 'information_schema')    AND C.relkind <> 'i'    AND nspname !~ '^pg_toast'  ORDER BY pg_total_relation_size(C.oid) DESC  LIMIT 20;

The result of this query will show the name of the table and its disk usage for the 20 biggest tables. Once you know which tables are growing very fast you can focus the analysis on the corresponding module.

You can find useful information about disk usage under: https://wiki.postgresql.org/wiki/Disk_Usage


Best regards

Yvan

Avatar
Discard
Author

Thank you Yvan, you saved the day ;). It seems that product_template table that has the most data in it (11Gb out of total 12Gb). Actually i was attching the logos of the main suppliers to the corresponding products as binary files and this was the reason.

Author

I did an update query on the product_template table in order to erase the value of "image_medium" and "image_small" columns, however the size of the table still not decreased.

How can i effectivelly delete those binary images from the database or from /var/lib/postgresql/9.4/main/base/my_db/ ?

Hi Thicham, i'm glad to hear that you were able to find the source of the problem.

Now that you have deleted the a huge amount of data, you need to perform a vacuum on the database using following command:

$ vacuumdb -d <name of your database> -t product_template

After that, you database should be a few GB smaller.

If you need further information about database vacuum, try this link:

https://www.postgresql.org/docs/8.4/static/sql-vacuum.html

Best Answer

Also review your attachment , May be attachment store internally as binary files

Avatar
Discard
Author Best Answer

That works just fine Yvan. Thanks a lot.

Avatar
Discard
Best Answer

For vacuum db, so All Log Note (history message) in each module will be delete too?
I Have same problem, public mail message reach 370 GB, my odoo server cannot online again.

How about this?

Thank you

Avatar
Discard