Created
November 1, 2013 10:49
-
-
Save rapimo/7263779 to your computer and use it in GitHub Desktop.
postgres order of columns matters
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 TABLE small ( | |
a smallint, | |
b smallint, | |
c integer, | |
d integer, | |
e date | |
) | |
CREATE TABLE big ( | |
c integer, | |
a smallint, | |
e date, | |
b smallint, | |
d integer | |
) | |
INSERT INTO small (a,b,c,d,e) | |
SELECT i%32000, i%15000, i+1000,i+3000,current_date + i | |
FROM generate_series(1,1E6::integer) i | |
INSERT INTO big (a,b,c,d,e) | |
SELECT i%32000, i%15000, i+1000,i+3000,current_date + i | |
FROM generate_series(1,1E6::integer) i | |
SELECT pg_size_pretty(pg_total_relation_size('small')); | |
pg_size_pretty | |
---------------- | |
42 MB | |
(1 row) | |
SELECT pg_size_pretty(pg_total_relation_size('big')); | |
pg_size_pretty | |
---------------- | |
50 MB | |
(1 row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://wiki.postgresql.org/wiki/Alter_column_position