Skip to content

Instantly share code, notes, and snippets.

@x4m
x4m / Deep RelationBuildDesc
Created August 8, 2021 11:16
Deep RelationBuildDesc
Last login: Sun Aug 8 13:57:34 on ttys000
/usr/local/opt/python@3.9/bin/python3.9: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper')
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/local/opt/python/libexec/bin/python and that PATH is
set properly.
/Users/x4mmm/mdb-scripts/completion.zsh.inc:32: command not found: compdef
x4mmm@x4mmm-2osx postgresA % cd contrib/amcheck/
@x4m
x4m / Actually stress vxid conversion
Last active July 19, 2021 07:01
stress vxid->xid->2px
package main
import (
"fmt"
"github.com/jackc/pgx"
"math/rand"
"time"
)
var timeToExit = false
@x4m
x4m / gist:4b30451dd2882c3266015aa55d3a3173
Created December 10, 2020 06:58
Recrete pg_partitions
SET allow_system_table_mods = true;
ALTER VIEW pg_catalog.pg_partitions RENAME TO pg_partitions_lock;
create view pg_catalog.pg_partitions as
select
schemaname,
tablename,
partitionschemaname,
partitiontablename,
@x4m
x4m / g1.sh
Created February 26, 2018 09:05
Intra-page indexing benchmark
#!/usr/bin/env bash
set -e
declare -a blksz=("2048" "4096" "8192" "16384" "32768")
declare -a trshs=("8" "16" "24" "32")
## now loop through the above array
for size in "${blksz[@]}"
do
\timing
create table r as
select int4range(g, g+10) ir, g g
from generate_series(1,1000000) g
order by random();
create index r_idx on r using gist (ir);
\timing
create extension if not exists pg_background;
create table input as select round(random()*20) x from generate_series(1,5,1);
create table output(place int,value int);
create sequence s start 1;
create table handles as select pg_background_launch('select pg_sleep('||x||'); insert into output values (nextval(''s''),'||x||');') h from input;
float pack_float_bits(const float v, const int r)
{
union {
float f;
struct { unsigned value:31, sign:1; } vbits;
struct { unsigned value:29, realm:2, sign:1; } rbits;
} a;
a.f = v;
a.rbits.value = a.vbits.value >> 2;
\timing
SET client_min_messages = 'DEBUG5';
SET log_min_messages = 'DEBUG5';
SET wal_level = 'minimal';
create extension if not exists cube;
begin transaction;
SELECT setseed(.43);
\timing
SET client_min_messages = 'DEBUG5';
SET log_min_messages = 'DEBUG5';
SET wal_level = 'minimal';
create extension if not exists cube;
begin transaction;
SELECT setseed(.43);
\timing
SET client_min_messages = 'DEBUG5';
SET log_min_messages = 'DEBUG5';
SET wal_level = 'minimal';
create extension if not exists cube;
begin transaction;
SELECT setseed(.43);