This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# Draw psql output as iTerm2 v3 inline graph using matplotlib | |
# Author: Alexander Korotkov <[email protected]> | |
import sys | |
import re | |
import warnings | |
import matplotlib | |
matplotlib.use("Agg") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/pg_stat_kcache.c b/pg_stat_kcache.c | |
index 63fb4ec..0328209 100644 | |
--- a/pg_stat_kcache.c | |
+++ b/pg_stat_kcache.c | |
@@ -152,7 +152,7 @@ _PG_init(void) | |
* Define (or redefine) custom GUC variables. | |
*/ | |
RequestAddinShmemSpace(pgsk_memsize()); | |
- RequestAddinLWLocks(1); | |
+ RequestNamedLWLockTranche("pg_stat_kcache", 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE journal ( | |
id SERIAL PRIMARY KEY, | |
dt TIMESTAMP NOT NULL, | |
level INTEGER, | |
msg TEXT | |
); | |
CREATE INDEX journal_dt_idx ON journal (dt); | |
SELECT create_parent('public.journal', 'dt', 'time', 'daily', NULL, 290, NULL, '2016-01-01'); | |
INSERT INTO journal (dt, level, msg) | |
SELECT g, random()*6, md5(g::text) |