HiveBrain v1.2.0
Get Started
← Back to all entries
principlesqlMinor

Does MySQL 8 ASCII vs utf8mb4_0900_ai_ci size differ when only using ASCII characters?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
sizemysqlcharactersasciidifferdoeswhenusingonlyutf8mb4_0900_ai_ci

Problem

If I only use only ASCII characters, will VARCHAR (255) with utf8mb4_0900_ai_ci be larger on disk than VARCHAR (255) using ASCII?

Solution

Unless MySQL does something strange, using only ASCII characters (i.e. only values 0 - 127) should be the exact same encoding, and hence the exact same size, between ASCII, UTF-8, and many other 8-bit code pages. It's only when you hit code points above 127 (or 0x7F) that UTF-8 starts to require additional space (though technically speaking, standard ASCII only includes values 0 - 127, thus there are no code points above 127, thus all ASCII code points are encoded identically in UTF-8, which after all, was the design goal of UTF-8: full ASCII compatibility).

Context

StackExchange Database Administrators Q#269014, answer score: 5

Revisions (0)

No revisions yet.