Skip to content

Instantly share code, notes, and snippets.

@ronaldbradford
ronaldbradford / README-POKEMON.md
Last active March 13, 2023 23:00
Pokemon Decks
View README-POKEMON.md

Pokemon Decks

Alolan Vulpix VSTAR (SIT 34)

  • Vulpix Beta - 5 Mar 2023 (Fire & Dice - Bobby)
  • ARCEUS VSTAR WITH FLYING PIKACHU VMAX (JustInBasil)
  • ARTICUNO (JustInBasil)

About

  • Water Energy
@ronaldbradford
ronaldbradford / connection_breakdown.sql
Created February 23, 2023 17:48
A summary of incoming MySQL Connections
View connection_breakdown.sql
SELECT /* Host connections */ host, user, COUNT(*) AS host_connections
FROM information_schema.processlist
GROUP BY host, user;
SELECT /* Running connections per source/user/schema */ host,user,db,command,COUNT(*) AS running
FROM information_schema.processlist
WHERE command NOT IN ('Sleep','Daemon')
GROUP BY host, user;
SELECT /* thread counts */ variable_name, variable_value
@ronaldbradford
ronaldbradford / lambda.auto-shutdown.py
Created January 26, 2023 15:06
Autoshutdown AWS RDS Instances and Clusters
View lambda.auto-shutdown.py
# this Code will help to schedule stop the RDS databasrs using Lambda
# Yesh
# Version -- 2.0
# Adapted from https://aws.amazon.com/blogs/database/schedule-amazon-rds-stop-and-start-using-aws-lambda/
import boto3
import os
import sys
import time
from datetime import datetime, timezone
@ronaldbradford
ronaldbradford / filler.lua
Created January 4, 2023 19:41
Standalone sysbench mysql example lua script
View filler.lua
-- filler.lua
--
-- 1. Ensure you have a 'sysbench' user and privileges to manage objects in schema 'sysbench'. e.g.
--
-- mysql> CREATE USER sysbench@'%' IDENTIFIED BY 'RM#aEq29waQE';
-- mysql> GRANT ALL ON sysbench.* TO sysbench@'%';
-- mysql> CREATE SCHEMA sysbench;
--
-- 2. Create the filler table with:
--
@ronaldbradford
ronaldbradford / mysql_tables.sql
Created December 20, 2022 21:12
Gather details of the largest tables in a given MySQL schema.
View mysql_tables.sql
# Connect to your schema first, i.e. USE <schema>
SELECT if(length(table_name)>40,concat(left(table_name,38),'..'),table_name) AS table_name,
engine,row_format as format, table_rows, avg_row_length as avg_row,
round((data_length+index_length)/1024/1024,2) as total_mb,
round((data_length)/1024/1024,2) as data_mb,
round((index_length)/1024/1024,2) as index_mb
FROM information_schema.tables
WHERE table_schema=DATABASE()
ORDER BY 6 DESC;
@ronaldbradford
ronaldbradford / mysql_schemas.sql
Created December 20, 2022 21:10
Provide a summary of information about MySQL Schemas for a given instance.
View mysql_schemas.sql
SELECT table_schema,
SUM(data_length+index_length)/1024/1024 AS total_mb,
SUM(data_length)/1024/1024 AS data_mb,
SUM(index_length)/1024/1024 AS index_mb,
COUNT(*) AS tables,
CURDATE() AS today
FROM information_schema.tables
WHERE table_schema NOT IN ('mysql','information_schema','performance_schema','sys','_doit_statpack_mysql')
GROUP BY table_schema
ORDER BY 2 DESC;
@ronaldbradford
ronaldbradford / rds-mysql-binlog-analysis.sh
Created December 13, 2022 18:31
Read RDS MySQL binary logs and provide a statement summary (supports ROW)
View rds-mysql-binlog-analysis.sh
#!/usr/bin/env bash
#set -o errexit
set -o pipefail
[ -z "${TMP_DIR}" ] && TMP_DIR=/tmp
TMP_FILE=${TMP_DIR}/binlog.txt.$$
BINLOG_ADDITIONAL_ARGS=${BINLOG_ADDITIONAL_ARGS:- -vvv --base64-output=DECODE-ROWS}
BINLOG_FILE=$1
[ -z "${BINLOG_FILE}" ] && echo "ERROR: You must specify a MySQL binary Log file" && exit 1
@ronaldbradford
ronaldbradford / earthquakes.geojson
Created December 2, 2022 03:20
Earthquakes for Feb 22, 2022
View earthquakes.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ronaldbradford
ronaldbradford / README.md
Last active November 18, 2022 19:18
Show MySQL Deadlock content from INNODB STATUS
View README.md

Usage

mysql -u${DBA_USER} -p${DBA_PASSWD} -h ${INSTANCE_ENDPOINT} -e "SHOW ENGINE INNODB STATUS\G" | awk -f deadlock.awk
@ronaldbradford
ronaldbradford / perschema.sql
Created November 18, 2022 19:12
MySQL Per Schema Table Stats
View perschema.sql
################################################################################
# Name : perschema.sql
# Purpose : List details of the specific schema
# Author : Ronald Bradford http://ronaldbradford.com
# Version : 2 03-June-2009
################################################################################
SELECT NOW(), VERSION();
# Per Schema Queries