We had a MySQL server old enough to not have partitioning enabled, so we decided to take our largest tables and move all the old rows to another table. In case they were needed at some point, they'd be moved to the "recent table", to make its usage faster. Overall, it would mean we'd have:
- table_old: holding about 25Gb
- table_recent: holding about 1Gb
We would keep this proportion forever, trying to balance the amount of old data vs new data and keeping only data used last week onwards in the recent one.
This proved to be a little bit difficult to develop in a clean way, but it's working well now. By just editing the "recent date" threshold, we can balance how much data the recent table will hold. At some point, old rows would go to the old table, and if some old data was needed, it would be moved around beforehand.
Now, we moved to MySQL 5.7, and partitioning is a thing. It seems cleaner at a developer side, but I don't know if it would be as efficient as what we had now, meaning we could update one row's last_used_time field and pop it to the main table.
- Would MySQL still move those fields between partitions, if my partition is based on a varying field like this?
- Would partitioning the table make the system run faster, or keeping the data in different tables is better?
Best Answer
I doubt anyone can tell you whether the performance of your home-grown system will be better or worse than the performance of MySQL built-in partitioning.
In general, some thoughts:
Therefore:
This is all completely generic advice - I don't know anything about MySQL partitioning (or about your solution, for that matter). I have built some system where we created our own solution instead of using existing products, though. I know that sometimes they work much better for your needs - but they do require maintenance, and switching to using a tool less tailored to your specifics can eventually save you that maintenance time, but can cost you in terms of flexibility, and can take a while to understand as well as you understand your solution.
If your solution is low-maintenance and works well for you, with no major performance concerns, I'd be inclined to maintain it for now at least. However, given the time to explore and the fact that there may now be a built-in solution as good or better than what you have, I'd want to check it out and see if it'd work for you.