4

So, a lot of databases will store the length prefix for a 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).

4

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.