Created
December 19, 2022 08:20
-
-
Save Jacke/2531b21d26230fa2144ffe5075bc3cae to your computer and use it in GitHub Desktop.
Postgres Data generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE UNLOGGED TABLE test_table ( | |
id bigint /*primary key*/ not null, | |
text1 text not null, /* 1 KiB of random data */ | |
text2 text not null, /* 255 bytes of random data */ | |
/* cardinality columns */ | |
int1000 bigint not null, /* ranges 0..999, cardinality: 1000 */ | |
int100 bigint not null, /* 0..99, card: 100 */ | |
int10 bigint not null /* 0..10, card: 10 */ | |
); | |
INSERT INTO test_table | |
SELECT | |
id, | |
(select string_agg(random()::text,'') from generate_series(1,52)) text1, /* length(random()::text) ~19B */ | |
(select string_agg(random()::text,'') from generate_series(1,14)) text2, | |
random()*1000 int1000, | |
random()*100 int100, | |
random()*10 | |
FROM | |
generate_series(1, 1e7) id; /* 10M rows ~ 13GB table */ | |
VACUUM ANALYZE test_table; | |
SELECT pg_size_pretty(pg_table_size('test_table')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment