How Many Records Can a MySQL Database Hold? A Complete Guide to MySQL Limits

Discover how many records a MySQL database can hold based on storage engines, table size, and hardware. Learn about InnoDB and MyISAM limits, practical constraints, and real-world examples of handling billions of rows in MySQL. Learn about the maximum number of records a MySQL database can store. This guide explains MySQL’s storage limits, table size constraints, and practical tips for managing large datasets with InnoDB and MyISAM storage engines.

The number of records a MySQL database can hold depends on several factors such as:

  • Storage engine (e.g., InnoDB, MyISAM)
  • Table structure
  • Storage capacity of the hardware
  • Operating system limits
  • Configuration settings (e.g., InnoDB file limits)

Here’s a breakdown of the key factors and theoretical limits.

Maximum Database Size Limits

Theoretically, a MySQL database can store up to 256 TB of data with InnoDB. The actual number of rows depends on:

  1. Table size limit
    • InnoDB tables can grow up to 64 TB in size, depending on the file-per-table setting and file system.
  2. Row size
    • InnoDB supports rows up to 16 KB in size. Larger text or blob fields are stored outside the row itself.
  3. Number of rows per table
    • The InnoDB storage engine does not impose a hard limit on the number of rows. The practical limit depends on storage capacity and row size.
    • If each row is 1 KB, you can theoretically store 64 billion rows in a 64 TB table.

Practical Limits Based on Storage Engines

Storage EngineMaximum Table SizeTheoretical Max Rows
InnoDB64 TB100s of billions
MyISAM256 TB2^32 (4.2 billion rows)

InnoDB Limits (Detailed)

InnoDB uses a primary key index to organize data. The table size limit depends on:

  • Tablespace size: The default maximum is 64 TB.
  • File-per-table mode: Allows each table to have its own file, making large datasets more manageable.
  • Row size: Rows can be 16 KB, but larger fields are stored separately.

Formula to estimate rows:

Given a table with 1 KB rows and a table size of 64 TB:

Number of Rows = 64 TB / 1 KB = 64×1012

Practical Factors Limiting Number of Rows

  1. Hardware Resources
    • Disk space, memory, and CPU power play a crucial role.
  2. File System Limits
    • NTFS (Windows): Supports files up to 256 TB.
    • EXT4 (Linux): Supports files up to 1 EB (exabyte).
  3. MySQL Configuration Limits
    • Maximum tablespace size
    • Buffer pool size
    • Log file size

Real-World Example: Billions of Rows

Many companies store billions of rows in MySQL databases:

  • Facebook: Uses MySQL for parts of their infrastructure.
  • Uber: Manages billions of rows across sharded MySQL databases.

Summary of Limits:

FactorLimit
Maximum DB Size256 TB (InnoDB)
Maximum Table Size64 TB (InnoDB)
Maximum Rows per TableTheoretically unlimited (depends on row size)

Conclusion:

There is no strict "maximum number of rows" for a MySQL database, but billions to hundreds of billions of rows are feasible depending on the hardware and configuration. In practice, performance optimizations (like partitioning, sharding, and indexing) are crucial for handling very large datasets.