简体   繁体   中英

Does table size affect INSERT performance?

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 [ie, 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.

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.

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.

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM