Does table size affect INSERT performance?

2019-04-08 13:06发布

This is a question just for the sake of asking:

Barring all intermediate to advanced topics or techniques (clustered indices, BULK INSERTS, export/import tricks, etc.), does an INSERT take longer the larger a table grows?

This assumes that there is only one auto-int column, ID [i.e., all new rows are INSERTED at the bottom, where no memory has to shuffled to accommodate a specific row positioning].


A link to a good "benchmarking MySQL" would be handy. I took Oracle in school, and so far the knowledge has done me little good on SO.

Thanks everyone.

4条回答
forever°为你锁心
2楼-- · 2019-04-08 13:48

I can only share my experience. hope it helps.

I am inserting lots of rows at the time, on huge database (several millions of entries). I have a script which prints the time before and after I execute the inserts. well I haven't seen any drop in performances.

Hope it gave you an idea, but I am on sqlite not on mysql.

查看更多
我想做一个坏孩纸
3楼-- · 2019-04-08 13:48

The speed is not affected as long as MySQL can update the full index in memory, when it begins to swap out the index it becomes slower. This is what happens if you rebuild an enormous index instantly using ALTER TABLE.

查看更多
趁早两清
4楼-- · 2019-04-08 14:00

Yes, but it's not the size of the table per se but the size of the indices that matter. Once index rewriting begins to thrash the disk, you'll notice a slowdown. A table with no indexes (of course, you'd never have such a thing in your database) should see no degradation. A table with minimal compact indexes can grow to a very relatively large size without seeing degradation. A table with many large indices will start to degrade sooner.

查看更多
Rolldiameter
5楼-- · 2019-04-08 14:06

My experience has been that performance degrades if the dataset index no longer fits in memory. Once that happens, checks for duplicate indexes will have to hit disk and it will slow down considerably. Make a table with as much data as you think you'll have to deal with, and do some testing and tuning. It's really the best way to know what you'll run into.

查看更多
登录 后发表回答