Tuesday, December 02, 2008

MySQL::SlowLog::Filter

we are using mysqlsla to parse MySQL slow.log, but we have an issue that our slow.log is pretty huge, it contains 2 years' data. somehow I just need 3 month or half a year.

I'm searching around to find a script to do the things I want and I find http://code.google.com/p/mysql-log-filter/
it's python(php) script and I do want a Perl script.

then http://search.cpan.org/dist/MySQL-SlowLog-Filter/ is out.
and a script: http://search.cpan.org/dist/MySQL-SlowLog-Filter/script/mysql_slowlog_filter.pl

have fun

Labels: ,

Wednesday, March 05, 2008

MySQL tip TIMESTAMPDIFF

Thanks for my college CY.

UNIX_TIMESTAMP(birthday) is not working when birthday is before 1970.
I should use TIMESTAMPDIFF(DAY, '1900-01-01', birthday) to get the DAY or SECOND
mysql> select TIMESTAMPDIFF(DAY, '1900-01-01', '1998-05-01');
+------------------------------------------------+
| TIMESTAMPDIFF(DAY, '1900-01-01', '1998-05-01') |
+------------------------------------------------+
| 35914 |
+------------------------------------------------+


http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff

in Perl, we can do:
use Date::Calc qw/Delta_Days/;
print Delta_Days(1900,1,1, 1998,5,1);
^Z
35914

Labels: