Como debuggar um banco de dados MySQL

## 1) Enter MySQL
mysql -u root -p
 
## 2) Let's see the list of locked tables
show open tables where in_use>0;
 
## 3) Let's see the list of the current processes,
## one of them is locking your table(s)
show processlist;
 
## 4) Kill one of these processes
kill <put_process_id_here>;

Inside Kubernetes

# Run db client in a pod inside kubernetes
kubectl run galera-mariadb-galera-client -n shared-qa --rm --tty -i --restart='Never' --image REGISTRY/mariadb-galera:10.4.12-debian-10-r78 --command -- mysql -h galera-mariadb-galera -P 3306 -uroot -pPASSWORD

Queries para encontrar problemas de desempenho

-- Use o EXPLAIN para entender o plano de execução de uma consulta problemática
EXPLAIN SELECT * FROM sua_tabela;
 
-- Print all killable queries
SELECT GROUP_CONCAT(CONCAT('KILL ',id,';') SEPARATOR ' ')
FROM information_schema.processlist WHERE user <> 'system user';
 
-- Print all queries from specific user
SELECT GROUP_CONCAT(CONCAT('KILL ',id,';') SEPARATOR ' ')
FROM information_schema.processlist WHERE user = 'joaozinho';