Thanks all for the help on getting my log_addpartition event running, dynamic SQL was just the ticket.
Thanks all for the help on getting my log_addpartition event running, dynamic SQL was just the ticket.
I want to create a log table in 5.1 that is partitioned by day. I want to roll-off old data and create new partitions for each day automatically. Without writing a script and a cronjob, it seems like this should be possible with Events. Let's start with the table:
create table log (
logged datetime not null,
id int not null auto_increment,
text varchar(256),
PRIMARY KEY ( logged, id )
)
PARTITION BY RANGE( TO_DAYS( logged ) ) (
PARTITION p20080206 VALUES LESS THAN (733444),
PARTITION p20080207 VALUES LESS THAN (733445),
PARTITION p20080208 VALUES LESS THAN (733446)
);This seems pretty straight-forward: I take my log entry time and convert it TO_DAYS and partition on that. I have tomorrow's partition all ready to go, just in case I don't get around to adding it today. Let's create an Event to do add tomorrow's partition for us automatically each day:
I've completed a beta implementation of my take on the replication pre-cache tool... Sorry nothing to download yet, I have to get it through an internal committee at Yahoo before I can release it (and you can imagine things are kind of crazy here). I wrote it myself because:
It's just over 250 lines of Ruby, my new favorite language and fairly compact. It doesn't use the Ruby Mysql library, rather just IO.popen calls to the mysql command line client. I did this for two reasons:
Thanks to those who tried it out and left feedback, much appreciated.
Thanks to the few people who pointed out a copyright infringement with the name 'MySQL Gadgets' for my tool. It has now been renamed 'MyQ Gadgets'. This is actually more appropriate (but hopefully not a violation of some other copyright), since I use the 'myq' prefix on my MySQL scripts as an easy, unique prefix for command line tab completion in bash.