TIBCO LogLogic LMI - Easily compare result sets inside MySQL
book
Article ID: KB0077719
calendar_today
Updated On:
Products
Versions
TIBCO LogLogic Enterprise Virtual Appliance
all versions
Description
Sometimes when troubleshooting, it is useful to check if two queries return the same result set. If the set is small then it is easy to do this by eye. However, if the result set is in the hundreds or thousands of rows, it can become an onerous task. One easy way is to use md5sum to return the MD5 value for the entire result set. You can do this as follows:
Issue/Introduction
This article shows you how to easily compare if two queries return the same result set.
Resolution
mysql> pager md5sum PAGER set to 'md5sum'
# Original query mysql> SELECT ... 32a1894d773c9b85172969c659175d2d - 1 row in set (0.40 sec)
# Rewritten query - results don't match as indicated by differing checksum mysql> SELECT ... fdb94521558684afedc8148ca724f578 - 1 row in set (0.16 sec)
# Rewritten query - matching results based on matching checksum mysql> SELECT ... 32a1894d773c9b85172969c659175d2d - 1 row in set (0.17 sec)
The pager command is used inside MySQL to pass result sets to a Bash command, in this case md5sum. To reset to normal, just run the pager command with no arguments:
mysql> pager Default pager wasn't set, using stdout.