brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: psql \dt+ lists database tables with their size on disk

Database
~/tips/tip-database-psql-dt-plus-table-sizes

\dt+

Shows disk usage per table, index and database from the psql prompt.

Before I guess which table eats the disk, I let psql show the numbers.

\dt+
\di+
\l+

\dt+ adds a Size column to the table list. \di+ does the same for indexes, and \l+ shows the size of every database on the server. Without a pattern \dt+ only lists schemas on your search path. Pass a pattern such as \dt+ *.* to see all schemas, or \dt+ public.log* for a few tables.

The size in \dt+ covers the table and its TOAST data, but not its indexes, so a table can use more space than the column suggests. Add the \di+ figures to get the full picture.

Further reading: PostgreSQL documentation: psql

More Database tips mariadb -e 'CREATE DATABASE IF NOT EXISTS blog' mariadb-dump --no-create-info --insert-ignore shop orders > orders-rows.sql SELECT table_schema, table_name, CHECKSUM TABLE shop.orders; services: All Database tips (53) All topics

Link