This article is half-done without your Comment! *** Please share your thoughts via Comment ***
If you don’t know about the TOAST Table, please visit the below article.
PostgreSQL: What is TOAST (The Oversized-Attribute Storage Technique)
In this post, I am sharing a script to check the used space by the TOAST tables in the PostgreSQL.
We should avoid the auto-creation of TOAST table which is not suitable for database performance.
Using below script, you can find the size and can take the appropriate decision on the biggest TOAST table of your database.
Below script is returning two columns where relpages is a number of occupied pages by the TOAST table. (1 page = 8kb)
1 2 3 4 5 6 7 8 9 10 11 |
SELECT relname ,relpages FROM pg_class, (SELECT reltoastrelid FROM pg_class) AS ss WHERE oid = ss.reltoastrelid OR oid = (SELECT indexrelid FROM pg_index WHERE indrelid = ss.reltoastrelid) ORDER BY relname; |