Skip to content

Instantly share code, notes, and snippets.

@morgo
morgo / pfs-histogram.txt
Created Apr 1, 2020
Performance Schema Histogram
View pfs-histogram.txt
WITH histogram AS (
SELECT
digest,
CASE
WHEN bucket_timer_low > 10000000000000 THEN '10s'
WHEN bucket_timer_low > 1000000000000 THEN '1s'
WHEN bucket_timer_low > 100000000000 THEN '100ms'
WHEN bucket_timer_low > 10000000000 THEN '10ms'
WHEN bucket_timer_low > 1000000000 THEN '1ms'
WHEN bucket_timer_low > 100000000 THEN '100us'
@morgo
morgo / pfs.txt
Created Mar 31, 2020
Performance Schema: summarize row locks of oldest 100 transactions
View pfs.txt
SELECT
thr.processlist_id AS mysql_thread_id,
FORMAT_PICO_TIME(trx.timer_wait) as trx_duration,
COUNT(case when lock_status='GRANTED' then 1 else null end) AS row_locks_held,
COUNT(case when lock_status='PENDING' then 1 else null end) AS row_locks_pending,
GROUP_CONCAT(DISTINCT CONCAT(object_schema, '.', object_name)) AS tables_with_locks
FROM
performance_schema.events_transactions_current trx
INNER JOIN performance_schema.threads thr USING (thread_id)
LEFT JOIN data_locks USING (thread_id)
View bench.go
package main
import (
"bytes"
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
"sync"
"time"
)
View setup_dm
#!/bin/bash
source ./sb_include
# Setup DM between sandboxes
SOURCE=$1
if [ -z "$SOURCE" ]; then
echo "Usage: "
@morgo
morgo / dm-sandbox-mysql-to-tidb.sh
Created Feb 25, 2019
Setup DM between MySQL 5.7 and TiDB Sandboxes
View dm-sandbox-mysql-to-tidb.sh
#!/bin/bash
killall -9 dm-master
killall -9 dm-worker
# Setup DM between sandboxes
MYSQL_PORT="5725"
TIDB_PORT="3000"
echo "Downloading required packages"
@morgo
morgo / mydumper-test-case
Created Oct 10, 2018
mydumper-test-case
View mydumper-test-case
MySQL [test]> create table t1 (a int not null primary key auto_increment, b char(255));
Query OK, 0 rows affected (0.51 sec)
MySQL [test]> create table t2 (a char(255) not null primary key, b char(255));
Query OK, 0 rows affected (0.51 sec)
MySQL [test]> INSERT INTO t1 values (1, 'aaa');
Query OK, 1 row affected (0.15 sec)
MySQL [test]> INSERT INTO t2 values ('aaa', 'aaa');
View gist:27673c86f1368aa8f20755f91b425316
morgo@ryzen:~/go/src/github.com/pingcap/tidb$ git diff
diff --git a/util/charset/charset_test.go b/util/charset/charset_test.go
index c400d97f..931b78ac 100644
--- a/util/charset/charset_test.go
+++ b/util/charset/charset_test.go
@@ -17,6 +17,8 @@ import (
"testing"
. "github.com/pingcap/check"
+ "github.com/pingcap/tidb/store/mockstore"
View percona.live.notes.md

Percona Server with XtraDB

Introduction

  • 2010(2009?) InnoDB 1.1 announced, will first ship with MySQL 5.5.
  • Historically InnoDB development lags while MySQL is trying to GA
  • lots of things fixed in InnoDB since MySQL 5.0
  • important note -- plugin version of InnoDB is not the default in 5.1
View gist:90e9531a664c0e89ded60487c2857d5a
# Initial Data does not make sense
# should be either "Harvey Dent" or "Two Face"
id: 1, firstname: "Two Face", lastname: "Dent"
# Assume RR isolation
session1.start
session2.start
View testcase-gaplocking
create table department (
id bigint not null,
budget bigint not null,
name varchar(255),
primary key (id)
) ENGINE=InnoDB;
create table employee (
You can’t perform that action at this time.