Skip to content

Instantly share code, notes, and snippets.

View akorotkov's full-sized avatar

Alexander Korotkov akorotkov

  • Supabase
View GitHub Profile
import numpy as np
import faiss
import seaborn as sns
import pandas as pd
# seed RNG for reproducible result
np.random.seed(1234)
nlist = 30
@akorotkov
akorotkov / init.sql
Last active May 27, 2020 09:39
bloat_bench
CREATE TABLE test (
id integer primary key,
value1 float8 not null,
value2 float8 not null,
value3 float8 not null,
value4 float8 not null,
ts timestamp not null
);
CREATE INDEX test_value1_idx ON test (value1);
@akorotkov
akorotkov / fastpath_lock_collision.sql
Created February 2, 2020 02:43
Fastpath lock collision generator
CREATE OR REPLACE FUNCTION int4_to_bytea(int8) RETURNS bytea AS
$BODY$
SELECT set_byte(' '::bytea, 0, ($1 % 256)::int4) ||
set_byte(' '::bytea, 0, (($1 / 256) % 256)::int4) ||
set_byte(' '::bytea, 0, (($1 / 65536) % 256)::int4) ||
set_byte(' '::bytea, 0, (($1 / 16777216) % 256)::int4);
$BODY$
LANGUAGE sql;
CREATE OR REPLACE FUNCTION int2_to_bytea(int4) RETURNS bytea AS
@akorotkov
akorotkov / pg_graph
Created June 5, 2016 10:21
Draw psql output as iTerm2 v3 inline graph using matplotlib
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Draw psql output as iTerm2 v3 inline graph using matplotlib
# Author: Alexander Korotkov <a.korotkov@postgrespro.ru>
import sys
import re
import warnings
import matplotlib
matplotlib.use("Agg")