Skip to content

Instantly share code, notes, and snippets.

CREATE UNLOGGED TABLE exclude_test(id integer primary key);
INSERT INTO exclude_test(id) SELECT generate_series(1,50000);
CREATE UNLOGGED TABLE exclude AS SELECT x AS item FROM generate_series(1,40000,4) x;
-- Horrific AND list, takes 80s to plan and execute here:
EXPLAIN ANALYZE SELECT id FROM exclude_test WHERE id <> 1 AND id <> 5 AND id <> 9 AND id <> 13 AND id <> 17 AND id <> 21 AND id <> 25 AND id <> 29 AND id <> 33 AND id <> 37 AND id <> 41 AND id <> 45 AND id <> 49 AND id <> 53 AND id <> 57 AND id <> 61 AND id <> 65 AND id <> 69 AND id <> 73 AND id <> 77 AND id <> 81 AND id <> 85 AND id <> 89 AND id <> 93 AND id <> 97 AND id <> 101 AND id <> 105 AND id <> 109 AND id <> 113 AND id <> 117 AND id <> 121 AND id <> 125 AND id <> 129 AND id <> 133 AND id <> 137 AND id <> 141 AND id <> 145 AND id <> 149 AND id <> 153 AND id <> 157 AND id <> 161 AND id <> 165 AND id <> 169 AND id <> 173 AND id <> 177 AND id <> 181 AND id <> 185 AND id <> 189 AND id <> 193 AND id <> 197 AND id <> 201 AND id <> 205 AND id <>
@biggert
biggert / audience-connect.png
Last active August 31, 2018 15:44
audience-connect model(s)
audience-connect.png
@biggert
biggert / gist:78b964e756bfd0bcb68c
Last active August 29, 2015 14:08
Cicayda Team LS
% ls -jeremy joebiggert@Joes-MacBook-Pro-3
ls: illegal option -- j
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
% ls -brandon joebiggert@Joes-MacBook-Pro-3
drwxr-xr-x 18 501 612 Oct 28 13:27 .
% ls -seth joebiggert@Joes-MacBook-Pro-3
total 496344
196360 Readable-100m.txt 29456 Readable-15m.txt 4912 Readable-2.5m.txt 280 Readable-500Lines-140k.txt
@biggert
biggert / gist:6453648
Created September 5, 2013 17:49
Get a clojure reader using the encoding by the BOM
(ns util
(:require [clojure.java.io :refer (file)]
[clojure.string :as str]
[clojure.java.io :as io])
(:import org.apache.commons.io.input.BOMInputStream
org.apache.commons.io.ByteOrderMark))
(def bom-array
(into-array [ByteOrderMark/UTF_16LE
ByteOrderMark/UTF_16BE
@biggert
biggert / gist:5584807
Created May 15, 2013 15:23
Why does parse-row work but add-bates-number not?
(defn parse-row
"Parse a row of text applying the headers in a keyword map"
[headers & opts]
(let [p #(parse %1 opts)]
(comp (partial zipmap headers) first p)))
(defn add-bates-number
"Add the bates-number key (and value) to the collection"
[h id-ord]
(comp #(conj {:bates-number (get %1 (keyword (nth h id-ord)))} %1)))