Optimizing datatypes

You should define tables such that they occupy minimum space on disk while accommodating all possible values.

If the size is smaller:

  • Less data is written to or read from the disk, which makes queries faster.
  • The contents on the disk are loaded to the main memory while processing queries. So, smaller tables occupy less space in the main memory.
  • Less space is occupied by indexes.

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.