Skip to content

Instantly share code, notes, and snippets.

View andyatkinson's full-sized avatar

Andrew Atkinson andyatkinson

View GitHub Profile
@andyatkinson
andyatkinson / enable_partitionwise_aggregate.sql
Created October 11, 2023 03:02
Exploring enable_partitionwise_aggregate
create table t (id serial, created_at timestamptz) partition by range (created_at);
create table t_202309 partition of t for values from ('2023-09-01') TO ('2023-10-01');
create table t_202310 partition of t for values from ('2023-10-01') TO ('2023-11-01');
postgres@[local]:5432 testing# \d t
Partitioned table "public.t"
Column | Type | Collation | Nullable | Default
------------+--------------------------+-----------+----------+-------------------------------
id | integer | | not null | nextval('t_id_seq'::regclass)
@andyatkinson
andyatkinson / postgresql.conf
Last active October 4, 2023 22:52
Enabling automatic query execution plans via auto_explain
# Prereq: auto_explain added to shared_preload_libraries
# Compute the Query Identifier
compute_query_id = on
# Logging duration
log_duration = on
# Logging Query Identifier (%Q)
log_line_prefix = 'pid=%p query_id=%Q: '
:quit
:qa
exit
exit!
quit
.quit
process.exit()
\q

Keybase proof

I hereby claim:

  • I am andyatkinson on github.
  • I am andatki (https://keybase.io/andatki) on keybase.
  • I have a public key whose fingerprint is 2BC1 EF01 7DEA 0698 523F 8A3C A6D9 3792 EFC7 54EE

To claim this, I am signing this object:

# example config from a nginx + unicorn + capistrano deploy to a VPS
# "app" is deployed to /var/www/app
# replace "app" with the app name
# The rule of thumb is to use 1 worker per processor core available,.
# however since we'll be hosting many apps on this server,.
# we need to take a less aggressive approach
worker_processes 2
# We deploy with capistrano, so "current" links to root dir of current release
unless File.exists?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'sqlite3'
GEMFILE
system 'bundle'
end

issues xfter a restart where postgres is running, but not with launchctl, not sure why stop manually:

pg_ctl -D /usr/local/var/postgres stop -s -m fast

restart with launchctl:

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist