Skip to content

Instantly share code, notes, and snippets.

View ololobus's full-sized avatar
👹

Alexey Kondratov ololobus

👹
View GitHub Profile
@ololobus
ololobus / branch-latency-test.py
Created March 22, 2023 16:10
Neon API latency test
#!/usr/bin/env python3
import requests
import time
import contextlib
from pprint import pprint
import psycopg2
@ololobus
ololobus / neon_wal_redo.c
Last active April 27, 2022 15:37
WAL redo checksum
// @@ -569,6 +569,21 @@ PushPage(StringInfo input_message)
/*
* Every backend on the compute side will verify the page checksum
* after reading it from pageserver using GetPage@LSN. Here in the
* WAL redo process we are reading pages directly from stdin, so we
* would better verify checksum too before applying any WAL records
* on top of it.
*/
if (!PageIsVerifiedExtended((Page) content, blknum,
PIV_LOG_WARNING | PIV_REPORT_STAT))
#!/usr/bin/env sh
export PATH=$(pwd)/target/debug/:$(pwd)/tmp_install/bin:$PATH
# Remove all traces of the previous run
killall pageserver
killall wal_acceptor
killall postgres
rm -rf zenith_tmp
@ololobus
ololobus / lock.c
Created January 28, 2021 10:29
PostgreSQL locks
/*
* Data structures defining the semantics of the standard lock methods.
*
* The conflict table defines the semantics of the various lock modes.
*/
static const LOCKMASK LockConflicts[] = {
0,
/* AccessShareLock */
LOCKBIT_ON(AccessExclusiveLock),
@ololobus
ololobus / pgbench-query.sql
Last active February 5, 2024 02:52
PostgreSQL pgbench schema
\set aid random(1, 100000 * :scale)
\set bid random(1, 1 * :scale)
\set tid random(1, 10 * :scale)
\set delta random(-5000, 5000)
BEGIN;
UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;
SELECT abalance FROM pgbench_accounts WHERE aid = :aid;
UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
@ololobus
ololobus / 0-A-Tour-of-Go.md
Last active July 8, 2020 21:39
A Tour of Go

A Tour of Go excersises

@ololobus
ololobus / 0-README.md
Last active October 11, 2021 11:39
PostgreSQL Multi-Tenant Sharding Test

PostgreSQL Multi-Tenant Sharding Test

Setup

  1. Create two Postgres clusters, one on 5432 port (node1) and one on 5433 (node2). Compile and install postgres_fdw extension on both.

  2. Set enable_partitionwise_join and enable_partitionwise_aggregate to on.

  3. Set postgres_fdw.use_remote_estimate to true.

@ololobus
ololobus / buffer.c
Created March 10, 2020 11:34
C fixed-size char buffer argument
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAXBUFSIZE 20
void put(char (*dest)[MAXBUFSIZE], char *src)
{
strcpy((char *) dest, src);
}
@ololobus
ololobus / extract-icu-collversions.md
Last active November 12, 2019 18:49
Get ICU collation versions per release and per language

Clone ICU repo:

git clone https://github.com/unicode-org/icu.git
cd icu

Run script:

python3 grep-icu.py
@ololobus
ololobus / logical-replication-test.sh
Last active September 19, 2024 13:23
PostgreSQL logical replication + pg_basebackup test
#!/bin/sh -ex
#export PATH=/usr/pgsql-11/bin:$PATH
pg_ctl stop -D /tmp/master || echo "ok"
pg_ctl stop -D /tmp/slave || echo "ok"
rm -rf /tmp/master
rm -rf /tmp/slave
# setup master
initdb -D /tmp/master