I read this excellent answer on optimal column ordering and noticed the summation:
Generally speaking, if you put the 8-byte-types first then the 4-byte-types and the 2-byte-types last you can't go wrong. Text or boolean do not have alignment restrictions like that, some other types do. In the end, you may save a couple of bytes per row at best. So, none of this is necessary for most people in most cases. But in your case it might save a couple of Gigabytes easily.
Does that mean that columns should be ordered from most space occupation to least?
If so, for
bytea columns that always have constant 16-byte, 32-byte, or 64-byte lengths, do the same rules apply? What about a text column that varies between 1kb to 5mb, heavily skewed to 1kb?
bytea columns are the variables used in all read conditions.
The upper limit on this table's length is tens of billions of rows per year.