Skip to content

Instantly share code, notes, and snippets.

View jberkus's full-sized avatar
💭
Catching up and prepping for Kubecon Shanghai

Josh Berkus jberkus

💭
Catching up and prepping for Kubecon Shanghai
View GitHub Profile
@jberkus
jberkus / gist:3950d8348e2ddb00070c
Last active January 13, 2018 06:52
New needed indexes query, temp version
WITH
write_adjust AS (
-- change the below to 1.0 if pg_stats goes back to
-- the creation of the database
SELECT 0.0 AS adjustment
),
index_usage AS (
SELECT sut.relid,
current_database() AS database,
sut.schemaname::text as schema_name,
# docker compose file for running a 3-node PostgreSQL cluster
# with etcd as the SIS
etcd:
image: quay.io/coreos/etcd
ports:
- "2379"
- "2380"
- "4001"
@jberkus
jberkus / cspace.txt
Created October 16, 2015 02:18 — forked from atman9/cspace.txt
Explain for query taking over 25mins to complete.
SELECT
h2.name AS "objectcsid",
cc.objectnumber,
h1.name AS "mediacsid",
mc.description,
bc.name,
mc.creator creatorRefname,
REGEXP_REPLACE(mc.creator, '^.*\)''(.*)''$', '\1') AS "creator",
mc.blobcsid,
mc.copyrightstatement,
root@dev-postgres:/var/lib/postgresql/pg_repack# make
make[1]: Entering directory `/var/lib/postgresql/pg_repack/bin'
gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -I/usr/include/mit-krb5 -fPIC -pie -DLINUX_OOM_SCORE_ADJ=0 -fno-omit-frame-pointer -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g pg_repack.o pgut/pgut.o pgut/pgut-fe.o -L/usr/lib/x86_64-linux-gnu -lpq -L/usr/lib/x86_64-linux-gnu -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -L/usr/lib/mit-krb5 -L/usr/lib/x86_64-linux-gnu/mit-krb5 -L/usr/lib/x86_64-linux-gnu -Wl,--as-needed -lpgport -lpgcommon -lssl -lcrypto -lkrb5 -lcom_err -lgssapi_krb5 -lz -ledit -lcrypt -ldl -lm -o pg_repack
/usr/bin/ld: cannot find -ledit
collect2: ld returned 1 exit status
make[1]: *** [pg_repack] Error 1
@jberkus
jberkus / gist:06055068f02a0eab6cd3
Last active January 13, 2018 06:50
polling pg_stat_activity
#!/bin/bash
NUMMIN=$(($1 * 2 + 10))
CURMIN=0
while [ $CURMIN -lt $NUMMIN ]
do
psql -q -t -A -c "SELECT now() as ts, state, client_addr, count(*) as num_conn, avg(now() - query_start) as avg_query, \
max(now() - query_start) as max_query, avg(now() - xact_start) as avg_xact, \
# This dockerfile is meant to help with setup and testing of
# patroni nodes. Unlike the prior docker setup, it relies on
# docker compose to set up multiple nodes.
FROM ubuntu:trusty
ADD . /setup/
RUN /setup/package_install.sh 9.4
@jberkus
jberkus / portlandhouselist.md
Created November 9, 2015 01:14
Looking for Portland House

What we're looking for in a rental house in Portland:

Most stuff below is negotiable; we figure we'll find a place which meets 7 out of 10 criteria.

  • 1400 to 1900 sq. ft.
  • 2 to 3 bedrooms, 1.5 to 2 baths
  • $2100/month or less
  • Near Max or major bus line
  • Unfinished basement or extra-large garage or large garden shed
  • Cats OK
relname <E2><94><82> relnamespace <E2><94><82> reltype <E2><94><82> reloftype <E2><94><82> relowner <E2><94><82> relam
<E2><94><82> relfilenode <E2><94><82> reltablespace <E2><94><82> relpages <E2><94><82> reltuples <E2><94><82> relallvisible <E2><94><82> reltoastrelid
<E2><94><82> relhasindex <E2><94><82> relisshared <E2><94><82> relpersistence <E2><94><82> relkind <E2><94><82> relnatts <E2><94><82> relchecks <E2><94>
<82> relhasoids <E2><94><82> relhaspkey <E2><94><82> relhasrules <E2><94><82> relhastriggers <E2><94><82> relhassubclass <E2><94><82> relispopulated <E2>
<94><82> relreplident <E2><94><82> relfrozenxid <E2><94><82> relminmxid <E2><94><82> relacl <E2><94><82> reloptions
<E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94>
<80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94><80><E2><94>
@jberkus
jberkus / badge_prefs.md
Last active December 1, 2015 04:10
badge preferences

##Badge Type

Good: Badge is plastic envelope with paper inside, has cord attachments on both corners to not flip, and is printed on both sides.

Better: Badge is a preprinted, recycleable plastic card printed on both sides (ala DockerCon).

Best: Badge is a little booklet with the summary conference schedule inside. Printed/stickered on both covers with my information.

Fun Alternative: no badges, only name stickers (PyDX).

psql --tuples-only --no-align --command "select setting, reset_val from pg_settings where name = 'log_min_duration_statement'"
https://dl.dropboxusercontent.com/u/5132935/healthcheck.tgz