When Does a MySQL Table Hit Its Limits? Insights and Demo
This article explains that MySQL imposes no fixed row limit, discusses the common 5‑million‑row myth and Alibaba's 2 GB recommendation, shows a Java insertion test that slows after millions of rows, and highlights how InnoDB buffer size and memory constraints affect table performance.
MySQL itself does not impose a hard limit on the number of rows in a single table; the limit is determined by the operating system’s file size constraints, with a common industry myth of 5 million rows.
Alibaba’s “Java Development Manual” recommends sharding when a single table exceeds 5 million rows or 2 GB in size.
A simple test
The following Java method repeatedly inserts rows into a users table while printing the count to the console.
private static void insertDataDemo() {
DButil dButil = new DButil();
myCon = dButil.getConnection();
try {
int i = 0;
while (1 == 1) {
i++;
String sql = "insert into users (user_name,user_password)"
+ " value ('" + i + "','password')";
sta = myCon.createStatement();
sta.execute(sql);
System.out.println(i);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
dButil.close();
}
}After running overnight, more than two million rows were inserted, but the insertion speed slowed to one row every 2–3 seconds, which is unacceptable.
The maximum data volume a MySQL table can hold is not related to the row count but to MySQL configuration and hardware. MySQL loads table indexes into memory for performance; sufficient InnoDB buffer size allows full in‑memory loading and fast queries.
When a table grows beyond the memory capacity for its indexes, queries incur disk I/O, causing performance degradation. The exact impact also depends on table schema design, but the root cause is memory limitation.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Backend Technology
Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
