patternMinor
Storage size for varchar length in Redshift
Viewed 0 times
redshiftsizelengthstoragevarcharfor
Problem
So, a lot of databases will store the length prefix for a
In contrast to CHAR, VARCHAR values are stored as a 1-byte or 2-byte length prefix plus data. The length prefix indicates the number of bytes in the value. A column uses one length byte if values require no more than 255 bytes, two length bytes if values may require more than 255 bytes.
I'm wondering if the same thing is true for Redshift? I've scoured the docs, but can't find it for the life of me!
Incidentally, I ask the question because a coworker built our entire data warehouse using
varchar field in 1 byte if the length is less than 255, and 2 bytes if it is more. For example, the MySQL docs say:In contrast to CHAR, VARCHAR values are stored as a 1-byte or 2-byte length prefix plus data. The length prefix indicates the number of bytes in the value. A column uses one length byte if values require no more than 255 bytes, two length bytes if values may require more than 255 bytes.
I'm wondering if the same thing is true for Redshift? I've scoured the docs, but can't find it for the life of me!
Incidentally, I ask the question because a coworker built our entire data warehouse using
varchar(256) for most fields - all the restrictions of short field length, none of the benefits of 1-byte length storage (unless Redshift uses 2 bytes regardless).Solution
According to this page Redshift varchars use "4 bytes + total bytes for characters...". The varchar stored size is likely a much smaller issue with Redshift due to columns being compressed.
Context
StackExchange Database Administrators Q#99361, answer score: 4
Revisions (0)
No revisions yet.