I have a table that has reached nearly 3 million records. While I appreciate this amount may not be considered large relative to RDBMS, I have noticed slow down in operations that deal with this table. I feel I can optimize or re-architect it.
This is part of the database for the PocketBracket March Madness App. Essentially the table stores meta data for a one to many relationship (Brackets has many Bracket Picks). The twist is the demand on the table is different at times. For example, there is a short period (two weeks) where the table is performing mostly writes. But for the rest of the year it is mostly reads. Furthermore, a far majority of the records are not accessed.
Here is a screenshot of the current structure:

With that, here are some thoughts I have:
- Place the old records in a separate table. Decreases the amount of records, but would require code modifications.
- Denormalize the table so the models are 1-1 (i.e. condense all bracket picks into a single serialized column). Decreases the amount of records, but would require code modifications.
- Swap the table’s engine and or indexes during demand periods (i.e. InnoDB/MyISAM).
- Something I haven’t thought of…
I would appreciate your direction. In the end, I am fine with code changes, I just want to ensure I’m re-architecting in the right direction.
Before going crazy with “optimizations” like partitioning, sharding, denormalization etc… which will introduce just a lot of additional problems I would first try to detect what is causing the slow down.
To give you an example I have a table of around 30 millions record and I do quite a lot of inserts, and reads per second, and I can get query results of around 2000 records in less than 300 ms. (still it could be probably improved)
Additionally please keep in mind that partitioning makes sens when you can split the files between multiple disks and therefore you can increase the overall I/O. So in other words you would need to have a partition file per disk to achieve good performances.
So first of all it is important to have some more info
It could simply be that the table is just fragmented and the mysql config needs some more tuning.
First of all you should switch to innodb, like Vyktor suggested, and then you have also to configure the innod db buffer to an higher value. The default one is too low.
Here an example of my config file. Keep in mind that the parameters are tuned for my type of data and queries and server specs. Additionally I am using a variant of MySQL called percona, which could help you out as well, cause it is proved to be faster. On the site you can find some benchmarks.
I would also try to run a mysqlcheck. WARNING !!! it locks the table !
If you need more info about mysql tuning, this is a great blog