---
title: "Discussion on \"High Performance MySQL [Ch.4: Optimizing Schema and Data Types]\" | Hashnode"
description: "Discussion on \"High Performance MySQL [Ch.4: Optimizing Schema and Data Types]\". So the last 2 articles discussed chapter 2 and 3 of High Performance MySQL titled Benchmarking MySQL and Profiling Server Performance respectively. Today's article will go a bit deeper into MySQL schema design and discuss chapter 4 titled Optimizing ..."
url: "https://hashnode.com/posts/high-performance-mysql-ch4-optimizing-schema-and-data-types/607ac811c99e200d08f7acea"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [High Performance MySQL \[Ch.4: Optimizing Schema and Data Types\]](https://sayedalesawy.hashnode.dev/high-performance-mysql-ch4-optimizing-schema-and-data-types?utm_source=hashnode&utm_medium=feed)

So the last 2 articles discussed chapter 2 and 3 of High Performance MySQL titled Benchmarking MySQL and Profiling Server Performance respectively. Today's article will go a bit deeper into MySQL schema design and discuss chapter 4 titled Optimizing ...

Apr 17, 2021 · 22 min read · sayedalesawy.hashnode.dev  
Read the article

-   [#mysql](https://hashnode.com/tag/mysql)
-   [#databases](https://hashnode.com/tag/databases)
-   [#optimization](https://hashnode.com/tag/optimization)
-   [#performance](https://hashnode.com/tag/performance)
-   [#backend](https://hashnode.com/tag/backend)

## Written by

[Sayed Alesawy](https://hashnode.com/@sayedalesawy)

@sayedalesawy · Cairo, Egypt

  
[View profile](https://hashnode.com/@sayedalesawy)

Lead Software Engineer @ Instabug

Lead Software Engineer at Instabug | Backend team. Passionate about large scale server side applications and distributed systems. Cairo University - Faculty of Engineering grad.

## Responses 1

Markdown supported · ⌘↵ to post

[Amr Elmohamady](https://hashnode.com/@AmrElmohamady)

[Apr 29, 2024](https://hashnode.com/posts/high-performance-mysql-ch4-optimizing-schema-and-data-types/607ac811c99e200d08f7acea/comment/662fd4355a7cf505bda65afa)

> "The advantages of using a CHAR type specially for very short strings is that it can actually use less space because it doesn't need to store the size information and it's not prone to fragmentation."

When you mention row fragmentation while comparing char and VARCHAR, you mean storing some columns in off-page storage (overflow pages), right?

If so, the CHAR type can also be fragmented when using a `CHAR(255)` in utf8mb4 character set (default in MySQL) which has a max of 4 bytes per character (4\*255=1020 > 768). Fixed-length fields greater than or equal to 768 bytes are encoded as variable-length fields. So the CHAR type is actually prone to fragmentation.

[dev.mysql.com/doc/refman/8.3/en/innodb-row-format…](https://dev.mysql.com/doc/refman/8.3/en/innodb-row-format.html#innodb-row-format-dynamic)

Correct me if I am wrong or misunderstood. By the way, I am really enjoying the series so far.

[Sayed Alesawy](https://hashnode.com/@sayedalesawy)

[Apr 30, 2024](https://hashnode.com/posts/high-performance-mysql-ch4-optimizing-schema-and-data-types/607ac811c99e200d08f7acea/comment/662fd4355a7cf505bda65afa#reply-6631456d49b7876c4be48462)

Good point. You’re correct, but I think the author’s definition of “very short” strings is definitely way less than 255.

Also, a note throughout the book, it’s referencing mysql 5.7 (at least for the version I have read). They don’t differ on this particular detail tho.
