The only problem is that MySQL 5.1 is still in beta. The number of outstanding bugs is shrinking by the day, and the number of reported bugs is receding, but nonetheless, it's not a GA release, and therefore the conscientious DBA is (justly) reluctant at the idea of using it in production.
Those partitions, though, are really tempting. Perhaps we can play some trick to use them, while keeping our data safe.
There are ways where you could use MySQL 5.1 in production, especially partitions, without endangering your valuable data. The easiest one is with replication.
MySQL replication is a cheap, reliable, fast way of synchronizing data among servers and balancing the query load, if you are willing to split your application logic so that you write on one server (the master) and read from another one, or several ones (the slave).
One nice feature of MySQL replication is that it can work across versions, as long as the most recent one is used in the slave. So you can set your real production server as the master, running MySQL 5.0, the legitimate GA release, while the slave will run MySQL 5.1.
The steps to achieve this feat are simple:
- make sure that your master is using a binary log and has a unique server ID;
- create a user with REPLICATION SLAVE privileges;
- on the slave, install MySQL 5.1, with a different server ID, but don't start the replication yet;
- dump the data from master to slave, using the mysqldump options --master-data=1 and --single-transaction;
- On the slave, Alter the structure of the tables that you want to partition;
- start the slave.
Think of the advantages:
- You will speed up some of your expensive queries. (Beware. It is not always easy. You need to check your table design, but in the end, it works spectacularly);
- If you find a bug in 5.1, you can help the development without risking the integrity of your data, which is still safe inside the master.
2 comments:
Nice trick. But it will only work, if you issue very simple queries on a 5.0 master.
Replication didn´t worked for us with 5.0. Every new release has another bug.
So I would be very carefully to put a beta-release in production. Even if its only for reading.
Too bad you can't use this trick for deletes. Can't wait for this to go into production . . . we need it like yesterday.
Post a Comment