Created
April 25, 2019 21:00
-
-
Save cgrayson/cc1e2da2e937cd2e21826bbffe63953d to your computer and use it in GitHub Desktop.
Watch the progress of a MySQL optimize, as the percentage size of the new temp file vs. the original
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Watch the progress of a MySQL optimize, as the percentage size of the new | |
# temp file vs. the original. Run in the MySQL data directory (wherever the | |
# .ibd files are). | |
# | |
# created: Aug 12, 2015 | |
# updated: Apr 25, 2019 | |
# | |
USAGE="$0: Usage is: $0 table-being-optimized" | |
TEMPTABLE=`ls -1 \#sql-*.ibd` | |
if [ -z "$1" ] | |
then | |
echo $USAGE | |
exit 32 | |
fi | |
TABLESIZE=`ls -l ${1}.ibd | awk '{ print $5; }'` | |
while [ -f $TEMPTABLE ] | |
do | |
s=`ls -l $TEMPTABLE | awk '{ print $5; }'` | |
# echo "scale=4;$s/$TABLESIZE" | bc | |
# following awk replaces above since bc isn't always available | |
awk -v NEWSIZE=$s -v OLDSIZE=$TABLESIZE 'BEGIN { printf ("%0.2f\n", ((NEWSIZE / OLDSIZE) * 100)); }' | |
sleep 180 | |
done | |
echo "Done!" | |
ls -l ${1}.ibd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment