I have a table of web users:
---- TABLE tb_user CREATE TABLE IF NOT EXISTS tb_user ( user_id SERIAL PRIMARY KEY NOT NULL, -- unique user_id user_firstname VARCHAR(31) NOT NULL, -- first name, in capitals, UTF8 user_familyname VARCHAR(62) NOT NULL, -- family name, in capitals, UTF8 user_email VARCHAR(71) NOT NULL, -- email, in lowercase, UTF8 user_gender CHAR(1) NOT NULL, -- 'F' | 'M' | '?' user_crtime DATE NOT NULL -- user entry creation time ); --- end TABLE tb_user
Imagine I have a million rows in that table, and 99% of users have a
user_firstname of less than 16 bytes, and 99% of users have a
user_family of less than 32 bytes.
Assume that this table is only filled by
INSERT SQL statements.
What would be the estimated disk space consumption of the PostgreSQL files (under
/var/lib/postgreql) containing that database. As measured by
For simplicity, assume that this table is the only one in the database.
To ask the question otherwise, the
VARCHAR(31) size is used for every row on disk, or not?
In other words, how practically important is the width of columns in tables, w.r.t to disk space?
Related question: How does Postgres store many varchars on disk?