Calculate the total size in bytes for a column
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2023 07:38 AM
I wanted to calculate the total size in bytes for a given column for a table. I saw that you can use the bit_length function and did something like this giving you the total bits of the column but not sure if this is correct.
SELECT sum(bit_length(to_binary(content, 'UTF-8'))) as total_bites FROM mytable;
When I look at running the DESCRIBE, the table sizeInBytes is way less then the above. Is that because the size in table is actually compressed vs the bit_length is calculating without compression?
DESCRIBE DETAIL mytable;