Skip to content

Instantly share code, notes, and snippets.

View datacharmer's full-sized avatar

Giuseppe Maxia datacharmer

View GitHub Profile
datacharmer / dbdeployer demo
Last active June 16, 2020 09:26
dbdeployer demo
View dbdeployer demo
### Dockerfile
FROM ubuntu:18.04
LABEL MAINTAINER Giuseppe Maxia <>
RUN groupadd -r msandbox \
&& useradd -m -s /bin/bash -g msandbox msandbox
datacharmer / tutorial Percona Live EU 2019
Last active September 28, 2019 14:23
tutorial Percona Live EU 2019
View tutorial Percona Live EU 2019
Use a Linux or Mac computer
Download at least the following 2 files:
1) . (~ 5MB)
2a) (Linux 42 MB)
2b) (Mac 148 MB)
datacharmer /
Last active August 13, 2019 10:34
test MySQL 8.0.17 CLONE
set -x
dbdeployer deploy single 5.7.26 --master --sandbox-directory=master_5_7_26 --port=18000 --db-password=different --db-user=different
dbdeployer deploy single 8.0.17 --master --sandbox-directory=master_8_0_17 --port=18001 --db-password=different --db-user=different
dbdeployer deploy single 8.0.17 --master --sandbox-directory=slave_8_0_17 --port=18002
~/sandboxes/master_5_7_26/use -t < fill.sql
du -sh ~/sandboxes/*/data
datacharmer / sample.txt
Last active June 8, 2019 20:41
sample master-master setup
View sample.txt
# Configuration node 1
user = gmax
port = 25617
socket = /tmp/mysql_sandbox25617.sock
basedir = /home/gmax/opt/mysql/8.0.16
datadir = /home/gmax/sandboxes/multi_msb_8_0_16/node1/data
tmpdir = /home/gmax/sandboxes/multi_msb_8_0_16/node1/tmp
pid-file = /home/gmax/sandboxes/multi_msb_8_0_16/node1/data/
bind-address =
datacharmer / purge process list from slow queries or idle connections
Last active March 2, 2020 15:49
These SQL procedures examine the process list and kill the queries that take more than N seconds to execute, or the connections idles for more than N seconds. Requires MySQL 5.1 or later. The companion events use the event scheduler to clean the process list every 30 seconds
View purge process list from slow queries or idle connections
-- SQL
drop procedure if exists purge_slow_queries;
drop procedure if exists purge_idle_connections;
drop event if exists auto_purge_slow_queries;
drop event if exists auto_purge_idle_connections;
delimiter //
create procedure purge_idle_connections()
datacharmer / partition_helper
Last active May 30, 2018 18:53
This script creates an ALTER TABLE statement to add or reorganize partitions for MySQL 5.1 or later.For usage: partition_helper --help
View partition_helper
# The MySQL Partitions helper
# Copyright (C) 2008-2015 Giuseppe Maxia
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
datacharmer / schema_comparison
Last active December 19, 2015 10:59
Poor man's schema comparison Given two database definitions, it displays the difference in their schemas
View schema_comparison
use strict;
use warnings;
use DBI;
my @dsn;
$dsn[0] = shift or help('no dns1');
$dsn[1] = shift or help('no dns1');
my @dbh;