Skip to content

Instantly share code, notes, and snippets.

View kmuthukk's full-sized avatar

Kannan Muthukkaruppan kmuthukk

View GitHub Profile
@kmuthukk
kmuthukk / ysql_group_by_index_col.py
Created September 27, 2020 03:14
Test case for GROUP BY index_column LIMIT n using table scan instead of index scan
# Dependencies:
# On CentOS you can install psycopg2 thus:
#
# sudo yum install postgresql-libs
# sudo yum install python-psycopg2
import psycopg2;
import time;
from datetime import datetime
from multiprocessing.dummy import Pool as ThreadPool
@kmuthukk
kmuthukk / ycql_non_index_update.py
Last active September 14, 2020 20:47
Check performance of updating a column that doesn't have an index
# pip install yb-cassandra-driver
from cassandra.cluster import Cluster
import time
import random
from multiprocessing.dummy import Pool as ThreadPool
from functools import partial
# Load Phase params
num_write_threads=2
@kmuthukk
kmuthukk / ysql-data-load.py
Created August 23, 2020 03:26
Loading CSV file to YB YSQL in smaller batches (rather than one large ACID transaction)
# sudo pip3 install pandas
# sudo pip3 install sqlalchemy
# sudo pip3 install psycopg2
# Imports
import pandas as pd
from sqlalchemy import create_engine
import psycopg2;
import time
@kmuthukk
kmuthukk / ycql_multiple_indexes.py
Last active August 21, 2020 02:25
ycql_multiple_indexes.py
# pip install yb-cassandra-driver
from cassandra.cluster import Cluster
import time
import random
from multiprocessing.dummy import Pool as ThreadPool
from functools import partial
# Load Phase params
num_write_threads=2
@kmuthukk
kmuthukk / ycql_table_row_count.py
Last active November 30, 2020 17:04
Script to get row counts for all tables in a YCQL keyspace
# pip install yb-cassandra-driver
from cassandra.cluster import Cluster
from cassandra.cluster import ResultSet
import time
import random
import os
from functools import partial
from multiprocessing.dummy import Pool as ThreadPool
@kmuthukk
kmuthukk / ycql_table_health_v1.py
Created July 15, 2020 18:08
A sample health check script to get 1 row from various partitions of the tables in a YCQL keyspace
# pip install yb-cassandra-driver
from cassandra.cluster import Cluster
# cluster = Cluster(['127.0.0.1'])
cluster = Cluster(['172.151.30.71', '172.151.28.193'])
num_checks_per_table=64
keyspace_name="ybdemo_keyspace"
# Dependencies:
# On CentOS you can install psycopg2 thus:
#
# sudo yum install postgresql-libs
# sudo yum install python-psycopg2
import psycopg2;
import time;
from datetime import datetime
from multiprocessing.dummy import Pool as ThreadPool
@kmuthukk
kmuthukk / ycql_parallel_connects.py
Last active June 3, 2020 22:30
Sample program to measure overhead of authenticated connections. Test case for https://github.com/YugaByte/yugabyte-db/issues/4596
# pip install yb-cassandra-driver
from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider
import time
import random
from multiprocessing.dummy import Pool as ThreadPool
num_sessions=10
<?php
$ip = '127.0.0.1';
$cluster = Cassandra::cluster()
->withDefaultConsistency(Cassandra::CONSISTENCY_QUORUM)
->withContactPoints($ip)
->build();
$session = $cluster->connect();
<?php
$ip = '127.0.0.1';
$cluster = Cassandra::cluster()
->withDefaultConsistency(Cassandra::CONSISTENCY_QUORUM)
->withContactPoints($ip)
->build();
$session = $cluster->connect();