Skip to content

Instantly share code, notes, and snippets.

View fritshoogland-yugabyte's full-sized avatar

Frits Hoogland fritshoogland-yugabyte

View GitHub Profile
# Dependencies:
# On CentOS you can install psycopg2 thus:
#
# sudo yum install postgresql-libs
# sudo yum install python-psycopg2
import psycopg2;
import time
import random
from multiprocessing.dummy import Pool as ThreadPool
@fritshoogland-yugabyte
fritshoogland-yugabyte / memory_filler.sql
Created February 8, 2022 12:12
PostgreSQL plpgsql memory filler
do $$
declare
filler text[];
counter int:=0;
begin
loop
filler[counter] := repeat('0123456789',1638);
counter:=counter+1;
end loop;
end $$;
@fritshoogland-yugabyte
fritshoogland-yugabyte / profile_call_times.awk
Last active October 23, 2021 10:46
Profile tserver time
#!/usr/bin/awk -f
#
# important: sed 's/\ \[wor/_[wor/'
#
{ process_name = $1;
pid = $2;
time = $4;
action = $5;
time = substr(time,1,length(time)-1);
if ( overall_begin_time == "" )
#!/usr/bin/awk -f
{ pid=$2;
time=$4;
action=$5;
# remove colon from time
time=substr(time,1,length(time)-1);
# get first relative timestamp in output
if ( overall_begin_time == "" )
@fritshoogland-yugabyte
fritshoogland-yugabyte / profile.awk
Last active October 4, 2021 08:32
Postgres activity and wait profile
#!/usr/bin/awk -f
{ pid=$2;
time=$4;
action=$5;
# wait groups
wait_class[0]="unknown";
wait_class[1]="lwlock";
wait_class[3]="lock";
wait_class[4]="buffer_pin";
#!/usr/bin/awk -f
{ pid=$2;
time=$4;
action=$5;
state=$7;
# backend states
backend_state[0]="undefined";
backend_state[1]="idle";
backend_state[2]="running";
@fritshoogland-yugabyte
fritshoogland-yugabyte / wait_events.awk
Created September 29, 2021 15:29
Wait events timing for postgres
#!/usr/bin/awk -f
{ pid=$2;
time=$4;
action=$5;
event_nr=$7;
# wait groups
wait_class[1]="lwlock";
wait_class[3]="lock";
wait_class[4]="buffer_pin";
#!/usr/bin/perl -w
#
# flamegraph.pl flame stack grapher.
#
# This takes stack samples and renders a call graph, allowing hot functions
# and codepaths to be quickly identified. Stack samples can be generated using
# tools such as DTrace, perf, SystemTap, and Instruments.
#
# USAGE: ./flamegraph.pl [options] input.txt > graph.svg
#
@fritshoogland-yugabyte
fritshoogland-yugabyte / check_orafce.sql
Last active September 28, 2021 17:56
Create TPCC warehouses PLpg/SQL and arrays
create or replace procedure check_orafce()
language plpgsql as $$
declare
orafce_available int;
orafce_installed int;
begin
select count(*) into orafce_available from pg_available_extensions where name = 'orafce';
if orafce_available > 0 then
raise info 'orafce extension available';
else
import java.sql.*;
import java.lang.*;
//
// javac -classpath postgresql-42.2.23.jar:. JdbcTest.java
// java -classpath postgresql-42.2.23.jar:. JdbcTest
//
public class JdbcTest {
private static final String user = "yugabyte";