Diamond Notes

Just another WordPress weblog

Tip of the Day — Checking Your Tables — Part II

To finish the discussion on the mk-table-checksum tool I wanted to let you know about the custom udf (user defined function) that Baron programmed for use in the maatkit toolkit. Essentially the udf provides a replacement for the md5 hash function. This function provides an impressive speedup. On two servers I ran the mk-table-checksum tool with the default setup and then installed the udf and re-ran the checksum tool. Here are the results:

server checksum w/md5 checksum w/fvn
db3 17m10.220s 5m0.090s
db6 112m21.719s 53m58.368s

Clearly it is a great benefit to use this udf if you are running table checksums.  So how do you set it up?  The source code is included in the tar.gz file that is distributed from the maatkit website.  Just download and unzip/untar.  In the included files there is a udf directory with one file.  To compile “just”:

gcc -fPIC -Wall -I/usr/include/mysql -shared -o fnv_udf.so fnv_udf.cc

The instructions are included in the source code.  Once you have it compiled, just copy the resultant file (fnv_udf.so) to the /lib directory and then run the command:

mysql mysql -e “CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME ‘fnv_udf.so’”

This adds the function to your MySQL server setup.  To test, log into mysql and make this call:

mysql> SELECT FNV_64(’hello’, ‘world’);

This should returns some results if everything is done properly.  Once your MySQL server “sees” the new udf maatkit will begin using it automatically.

Baron has an excellent background post on the fvn udf here: xaprb post

Thanks for the great tools Baron!!

No comments yet. Be the first.

Leave a reply