- Read every row in the table
- No reading of index. Reading from indexes is also expensive.
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
" Vim syntax file | |
" Language: SQL, PGSQL (postgres 9.1) | |
" Last Change: 2012 May 21st | |
" Maintainer: Grégoire Hubert <greg DOT hubert AT gmail DOT com> | |
" Based on the work of Paul Moore <pf_moore AT yahoo.co.uk> | |
" For version 5.x: Clear all syntax items | |
" For version 6.x: Quit when a syntax file was already loaded | |
if version < 600 | |
syntax clear |
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 | |
import redis | |
import random | |
import sys | |
r = redis.Redis(host = 'localhost', port = 6389) | |
REDIS_SETGET = False | |
REDIS_HSET = False |
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
# I am a scientist who has been using R for about 2 years. Today I achieved a measure of enlightenment into | |
# the zen of R, and I want to share it with you. | |
# I was simulating a set of independent random walks, which are formed by a multiplicative process. Here is | |
# the code I had built up over a few months of working on it and modifying it on and off as research | |
# questions changed: | |
TimeSteps <- 1000 | |
Walks <- 100 | |
ErrorMagnitude <- 0.03 |
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
# http://openmymind.net/Paging-And-Ranking-With-Large-Offsets-MongoDB-vs-Redis-vs-Postgresql/ | |
lids = ['4fe907f1210b2e9e3080f001', '4fe907f1210b2e9e3080f002', '4fe907f1210b2e9e3080f003', '4fe907f1210b2e9e3080f004', '4fe907f1210b2e9e3080f005'] | |
insert the data | |
open('data.csv', 'w') do |f| | |
6000000.times do |i| | |
f.puts "#{lids.sample},user_#{i},#{(rand() * 10000000).to_i}" | |
end | |
end |
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
# .png with Windows GDI versus .png with cairographics | |
doInstall <- TRUE # Change to FALSE if you don't want packages installed. | |
toInstall <- c("ggplot2", "RColorBrewer", "Cairo") | |
if(doInstall){install.packages(toInstall, repos = "http://cran.us.r-project.org")} | |
lapply(toInstall, library, character.only = TRUE) | |
# Generate some data | |
nn <- 100 | |
myData <- data.frame(X = rnorm(nn), |
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
———————————————————————————————————————————————————————————————————————————————————————————————————— | |
BBEDIT/TEXTWRANGLER REGULAR EXPRESSION GUIDE MODIFIED 2014-01-13 : 00:12 | |
———————————————————————————————————————————————————————————————————————————————————————————————————— | |
NOTES: | |
The PCRE engine (Perl Compatible Regular Expressions) is what BBEdit and TextWrangler use. | |
Items I'm unsure of are marked '# PCRE?'. The list while fairly comprehensive is not complete. |
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 urlparse | |
import argparse | |
import redis | |
import sys | |
from multiprocessing import Pool | |
import signal | |
def parse_redis_url(s): | |
url = urlparse.urlparse(s) | |
if not url.scheme: |
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
library(plyr) | |
find_zones <- function(x) { | |
x.mean <- mean(x) | |
x.sd <- sd(x) | |
boundaries <- seq(-4, 4) | |
# creates a set of zones for each point in x | |
zones <- sapply(boundaries, function(i) { | |
i * rep(x.sd, length(x)) | |
}) |
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
WITH btree_index_atts AS ( | |
SELECT nspname, relname, reltuples, relpages, indrelid, relam, | |
regexp_split_to_table(indkey::text, ' ')::smallint AS attnum, | |
indexrelid as index_oid | |
FROM pg_index | |
JOIN pg_class ON pg_class.oid=pg_index.indexrelid | |
JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace | |
JOIN pg_am ON pg_class.relam = pg_am.oid | |
WHERE pg_am.amname = 'btree' | |
), |
OlderNewer