This is part of a bash script code I wish to use multi-threading
for DATABASE in $DATABASES ; do
echo Converting $DATABASE
# Check if the table is MyISAM (we don't want to convert InnoDB tables over and over again)
TABLES=$(echo "SELECT TABLE_NAME FROM information_schema.TABLES where TABLE_SCHEMA = '$DATABASE' and ENGINE = 'MyISAM'" | $MYSQL_COMMAND)
for TABLE in $TABLES ; do
echo Converting MyISAM $TABLE to InnoDB
echo "ALTER TABLE $TABLE ENGINE = INNODB" | $MYSQL_COMMAND $DATABASE
done
if [ "x$TABLES" = "x" ] ; then
echo No MyISAM tables found in $DATABASE database
fi
echo
done
Is it possible for FOR
to use multi-threading?
I was thinking about rewriting the script and doing it with xargs -P3 -n1 -I{}
and so on, but it looks dirty to me.