Skip to content

Instantly share code, notes, and snippets.

View pdeaudney's full-sized avatar

Paul De Audney pdeaudney

View GitHub Profile
@pdeaudney
pdeaudney / jsonb_merge.sql
Created June 1, 2020 08:23 — forked from phillip-haydon/jsonb_merge.sql
Deep Merge two jsonb documents in PostgreSQL
CREATE OR REPLACE FUNCTION jsonb_merge(left JSONB, right JSONB) RETURNS JSONB AS $$
var mergeJSON = function (target, add) {
function isObject(obj) {
if (typeof obj == "object") {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
return true; // search for first object prop
}
}
@pdeaudney
pdeaudney / query_planner.markdown
Created May 29, 2020 15:13 — forked from hgmnz/query_planner.markdown
PostgreSQL query plan and SQL performance notes

Types of index scans

Indexes

Sequential Scan:

  • Read every row in the table
  • No reading of index. Reading from indexes is also expensive.

Tuning Storm+Trident

Tuning a dataflow system is easy:

The First Rule of Dataflow Tuning:
* Ensure each stage is always ready to accept records, and
* Deliver each processed record promptly to its destination
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script set ownership for all table, sequence and views for a given database
Credit: Based on http://stackoverflow.com/a/2686185/305019 by Alex Soto
#!/bin/bash
usage()
{
cat << EOF
usage: $0 options
This script sets ownership for all tables, sequences, views, and functions for a given schema.
Run this script as your postgres OS user.
@pdeaudney
pdeaudney / warranty.rb
Created February 18, 2012 01:14 — forked from frimik/warranty.rb
Dell warranty fact
# Dell Facter module
#
# Author: Mikael Fridh <mfridh@marinsoftware.com>
# Date: 2011-11-24
#
# this is a rather substantial rewrite of the camptocamp puppet module
# https://github.com/camptocamp/puppet-dell
#
# The regex matching has been ripped out completely and replaced with
# some xpath expressions from Nokogiri. Unfortunately this means another