Skip to content

Instantly share code, notes, and snippets.

@andyatkinson
Last active October 7, 2024 22:52
Show Gist options
  • Save andyatkinson/a10983394ce78c2d509cb0e7ac9fdc07 to your computer and use it in GitHub Desktop.
Save andyatkinson/a10983394ce78c2d509cb0e7ac9fdc07 to your computer and use it in GitHub Desktop.
psql> create table t(a uuid, b text, c char(36));
CREATE TABLE
psql> insert into t values (gen_random_uuid(), 'some amount of text', 'some amount of text');
INSERT 0 1
psql> select pg_column_size(a), pg_column_size(b), pg_column_size(c) from t;
pg_column_size | pg_column_size | pg_column_size
----------------+----------------+----------------
16 | 20 | 37
psql> insert into t values (gen_random_uuid(), gen_random_uuid(), gen_random_uuid());
INSERT 0 1
psql> select * from t;
a | b | c
--------------------------------------+--------------------------------------+--------------------------------------
1cbf80ed-a309-4163-8231-c5431e438500 | some amount of text | some amount of text
2a44f391-1e9d-4b0a-a15f-f7f12eb15cfc | 8daed507-a4f4-4b05-a3e6-dc3ac49856bf | 12355217-df08-481d-8c1c-20d6b36c60a0
(2 rows)
psql> select pg_column_size(a), pg_column_size(b), pg_column_size(c) from t;
pg_column_size | pg_column_size | pg_column_size
----------------+----------------+----------------
16 | 20 | 37
16 | 37 | 37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment