tags:

views:

390

answers:

3

I'm doing a lot of INSERTs via LOAD DATA INFILE on MySQL 5.0. After many inserts, say a few hundred millions rows (InnoDB, PK + a non-unique index, 64 bit Linux 4GB RAM, RAID 1), the inserts slow down considerably and appear IO bound. Are partitions in MySQL 5.1 likely to improve performance if the data flows into separate partition tables?

A: 

If the columns INSERT checks (primary keys, for instance) are indexed - then this will only decrease the speed: MySQL will have to additionally decide on partitioning.

All queries are only improved by adding indexes. Partitioning is useful when you have tons of very old data (e.g. year<2000) which is rarely used: then it'll be nice to create a partition for that data.

Cheers!

o_O Tync
The performance of all queries is not helped by indexing: performance of INSERTs are hurt by indexing.
njk
+1  A: 

The previous answer is erroneous in his assumptions that this will decrease performance. Quite the contrary.

Here's a lengthy, but informative article and the why and how to do partitioning in MySQL:

http://dev.mysql.com/tech-resources/articles/performance-partitioning.html

Partitioning is typically used, as was mentioned, to group like-data together. That way, when you decided to archive off or flat out destroy a partition, your tables do not become fragmented. This, however, does not hurt performance, it can actually increase it. See, it is not just deletions that fragment, updates and inserts can also do that. By partitioning the data, you are instructing the RDBMS the criteria (indeces) by which the data should be manipulated and queried.

Wayne Hartman
A: 

Edit: SiLent SoNG is correct. DISABLE / ENABLE KEYS only works for MyISAM, not InnoDB. I never knew that, but I went and read the docs. http://dev.mysql.com/doc/refman/5.1/en/alter-table.html#id1101502.

Updating any indexes may be whats slowing it down. You can disable indexes while your doing your update and turn them back on so they can be generated once for the whole table.

ALTER TABLE foo DISABLE KEYS;
LOAD DATA INFILE ... ;
ALTER TABLE ENABLE KEYS;

This will cause the indexes to all be updated in one go instead of per-row. This also leads to more balanced BTREE indexes.

PHP-Steven
the asker already mentioned InnoDb. disable keys and enable keys do not support InnoDb.
SiLent SoNG
@SiLent SoNG: Thanks, I didn't know it was MyISAM only. Post edited to reflect.
PHP-Steven