Is 20M of rows still a valid soft limit of MySQL table in 2023?
yishenggong.com
yishenggong.com
It's survived several HN death hugs.
Though I would say there are things you can do with a 20M table that you can't with a 1B table. If the query doesn't have an index, it will take hours. Even SELECT COUNT(*) takes like 10 min.
I reckon this is probably not true? If so, is it because it keeping a counter like that up-to-date would be inefficient
Edit: I just realized I might be misunderstanding what that query does
Meanwhile the primary key is typically the largest index, since with InnoDB's clustered index design, the primary key is the table. So it's usually not the best choice for counting unless there are no secondary indexes.
As other commenters mentioned, the query also must account for MVCC, which means properly counting only the rows that existed at the time your transaction started. If your workload has a lot of UPDATEs and/or DELETEs, this means traversing a lot of old row versions in UNDO spaces, which makes it slower.
I don't even know how to count that low
To get this info on your own mysql db: `select * from information_schema.TABLES;`. As previously disclaimed, the TABLE_ROWS here are an estimate generally, see https://dev.mysql.com/doc/mysql-infoschema-excerpt/5.7/en/in...
(same in MySQL 8; we use both 5.7 and 8)
https://planetscale.com/docs/learn/online-schema-change-tool...
The system design predates me, but it is solid (albeit difficult to operate at this scale - usual stuff like schema changes, replication bootstrapping).
Bootstrapping one from scratch (like if we need to stand up a new replica)? We restore a disk image on GCP from point in time snapshots, then let it catch up on replication. So it'll depend on how far behind it is when it comes online.
TLDR: a few hours in the worst case. ~Zero downtime in practice.
It’s all about logical I/O operations which, for an indexed read, would only be a handful regardless of size as it’s operating on a btree: https://en.m.wikipedia.org/wiki/B-tree
Now creating that index from scratch might take a while though…
https://dev.mysql.com/doc/refman/8.0/en/innodb-online-ddl-op...
People still think it's a toy to this day and they've struggled to shake that perception.
might need to fork/run this on psql to compare performance.
You can see where they come from when you consider some pretty static numbers in systems: like that page sizes are 4k, block sizes are usually pretty standard (512b or 4k) and network interfaces (at least the throughput) haven't increased for a decade or more.
Some of those rules need to be challenged as the technologies or systems change over time. 20M rows in a highly updated table should be an old "rule" though, at the latest from 2010, when mech drives were popular, because having your entire table index fitting on a few sectors on physical disk made a pretty substantial performance difference. Indexes need to flush to disk on update. (or they used to)
Pretty clearly people ran the exact same test, fill a table with a bunch of empty/meaningless data and see where performance degrades - then write a catchy headline title/post.
In the end, it's more nuanced than that but i think the overall theme is know your tuning once you get to certain data sizes.
Once data is cached, using indexed lookups are fast, 0.5ms.
The article shows that nothing notable happens at 20M, so what limits are you talking about?
One more level of depth on the B+ tree is very easy to deal with.