Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on How to calculate how much data is stored in a MySQL column?
Parent
How to calculate how much data is stored in a MySQL column?
I am considering either removing some columns or changing the datatypes if I could significantly reduce the amount of storage that is currently used by those columns. Some of the columns are ints and some are varchar.
How do I calculate (preferably in megabytes) the amount of storage a column uses?
Post
The reference indicated by jcsahnwaldt indeed specifies the space required by VARCHAR columns, namely (L = string length):
L + 1 bytes if column values require 0 − 255 bytes, L + 2 bytes if values may require more than 255 bytes
However, I think this is true only for non-Unicode characters and expect to have more depending on collation. This rather old answer from Stack Overflow suggests that a character might take up 1-4 bytes depending on the actual character / collation.
1 comment thread