Hacking with PHP has been updated for PHP 7 - click here! >>

Load data intelligently

When you add an index to your tables, MySQL needs to do a lot more work whenever it modifies that table - it needs to write the new value, as well as updating the index. As a result, you should be careful how you choose to load your data when you are creating a table and inserting lots of values.

If you find yourself in this situation, it is much faster to create the table without any indexing, add all the fields, then add the indexes.


If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Consider splitting off variable-length fields >>

Previous chapter: Declare fields NOT NULL

Jump to:


Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.