Skip to content

Instantly share code, notes, and snippets.

View AlexRogalskiy's full-sized avatar
🛰️
Work on stuff that matters

Alexander AlexRogalskiy

🛰️
Work on stuff that matters
View GitHub Profile
-- Step_1: setup
Create database testDB;
use testDB;
Create table t( a int, b varchar(70));
insert into t values (1, now(6));
insert into t select a+(select max(a) from t), now(6) from t;
select count(*) from t;
-- Step_3: updates on primary
insert into t values (-1, now(6));
@AlexRogalskiy
AlexRogalskiy / init.sql
Created August 10, 2021 07:04 — forked from robrich/init.sql
Get started with MemSQL on Windows
CREATE DATABASE IF NOT EXISTS hellomemsql;
USE hellomemsql;
CREATE TABLE IF NOT EXISTS messages (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
content varchar(300) NOT NULL,
createdate TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP
);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AlexRogalskiy
AlexRogalskiy / cluster1.sql
Created August 10, 2021 07:06 — forked from robrich/cluster1.sql
MemSQL Disaster Recovery - failback to primary cluster demo
-- Step_1: setup
Create database testDB;
use testDB;
Create table t( a int, b varchar(70));
insert into t values (1, now(6));
insert into t select a+(select max(a) from t), now(6) from t;
select count(*) from t; -- 262144
-- Step_3: updates on primary
insert into t values (-1, now(6));
@AlexRogalskiy
AlexRogalskiy / memsql-json.sql
Created August 10, 2021 07:06 — forked from robrich/memsql-json.sql
CRUD with JSON in MemSQL
create database acme;
use acme;
create table customer (
id int,
name varchar(200),
properties json not null,
key (id) using clustered columnstore
);
@AlexRogalskiy
AlexRogalskiy / reference-table.sql
Created August 10, 2021 07:06 — forked from robrich/reference-table.sql
Reference Tables
create database 'tpc_h';
use 'tpc_h';
CREATE TABLE IF NOT EXISTS `lineitem` (
`l_orderkey` bigint(11) NOT NULL,
`l_partkey` int(11) NOT NULL,
`l_suppkey` int(11) NOT NULL,
`l_linenumber` int(11) NOT NULL,
`l_quantity` decimal(15,2) NOT NULL,
`l_extendedprice` decimal(15,2) NOT NULL,
@AlexRogalskiy
AlexRogalskiy / backup-with-split-partitions.sql
Created August 10, 2021 07:06 — forked from robrich/backup-with-split-partitions.sql
MemSQL Backup with Split Partitions
-- create a database with 2 master partitions
create database thedb partitions 2;
-- create sample data
use thedb;
create table data (msg varchar(200));
insert into data (msg) values ('the data');
-- notice how we're not using the database efficiently
show partitions;
-- create a database
create database cosmeticshop;
-- create a table
use cosmeticshop;
create table cosmeticshopfunnel
(
event_time TIMESTAMP,
event_type CHAR(18),
product_id CHAR(10),
@AlexRogalskiy
AlexRogalskiy / gist:629254819b8442a32d86d7a7630c924b
Created August 10, 2021 08:23 — forked from robrich/gist:3b5ee06a1bc179f3c5cfce0055def5d4
MemSQL load-balanced failover queries.sql
-- MemSQL load-balanced failover
-- =============================
-- Queries demoing load-balanced failover in MemSQL: https://youtu.be/J86fLCMr5dc
create database x_db partitions 8;
select host, port, node_id, availability_group as AG from leaves order by AG;
SELECT master_host as m_host, master_port as m_port, host as repl_host, port as repl_port, GROUP_CONCAT(database_name ORDER BY database_name) AS list_partitions FROM information_schema.mv_cluster_status WHERE metadata_role='slave' GROUP BY master_host, master_port, repl_host, repl_port ORDER BY master_host, master_port, repl_host, repl_port;
@AlexRogalskiy
AlexRogalskiy / deployment.yaml
Created August 10, 2021 08:27 — forked from robrich/deployment.yaml
RedHat OpenShift + MemSQL Operator
apiVersion: apps/v1
kind: Deployment
metadata:
name: memsql-operator-envvar
namespace: memsql
spec:
replicas: 1
selector:
matchLabels:
name: memsql-operator-envvar