Only four values really matter:
- shared-buffers: below 2GB: set it to 20% of full memory; below 32GB: 25% of your full memory.
| What exactly is "iowait"? | |
| To summarize it in one sentence, 'iowait' is the percentage | |
| of time the CPU is idle AND there is at least one I/O | |
| in progress. | |
| Each CPU can be in one of four states: user, sys, idle, iowait. | |
| Performance tools such as vmstat, iostat, sar, etc. print | |
| out these four states as a percentage. The sar tool can | |
| print out the states on a per CPU basis (-P flag) but most |
| # This is just a cheat sheet: | |
| # On production | |
| sudo -u postgres pg_dump database | gzip -9 > database.sql.gz | |
| # On local | |
| scp -C production:~/database.sql.gz | |
| dropdb database && createdb database | |
| gunzip < database.sql.gz | psql database |
| # This is just a cheat sheet: | |
| # On production | |
| sudo -u postgres pg_dump database | gzip -9 > database.sql.gz | |
| # On local | |
| scp -C production:~/database.sql.gz | |
| dropdb database && createdb database | |
| gunzip < database.sql.gz | psql database |
| #!/bin/bash | |
| # extract all postgres databases from a sql file created by pg_dumpall | |
| # this script outputs one .sql file for each database in the original .sql file | |
| # unless you pass the name of a database in the dump | |
| if [ $# -lt 1 ] | |
| then | |
| echo "Usage: $0 <postgresql sql dump> [dbname]" >&2 | |
| exit 1 | |
| fi |
| 1) see re: increasing shmmax http://stackoverflow.com/a/10629164/1283020 | |
| 2) add to postgresql.conf: | |
| shared_preload_libraries = 'pg_stat_statements' # (change requires restart) | |
| 136 pg_stat_statements.max = 1000 | |
| 137 pg_stat_statements.track = all | |
| 3) restart postgres | |
| 4) check it out in psql |
| # Taken from http://robots.thoughtbot.com/post/33706558963/migrating-data-from-an-upgraded-postgres | |
| # | |
| # Note: these steps assume installation with Homebrew. | |
| # Initialize a new database, adding a .new suffix to the directory that Homebrew recommends. | |
| initdb /usr/local/var/postgres.new -E utf8 | |
| # Run the upgrade script, providing the correct paths for the various flags. |
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(query_start, clock_timestamp()), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(query_start, clock_timestamp()), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
| function isRansomNotePossible(newsArticle, ransomNote) { | |
| var availableChars = {}; | |
| for (var r = 0; r < newsArticle.length; r++) { | |
| var asciiCode = newsArticle.charCodeAt(r); | |
| availableChars[asciiCode] = (availableChars[asciiCode] || 0) + 1 | |
| } | |
| for (var r = 0; r < ransomNote.length; r++) { | |
| var asciiCode = ransomNote.charCodeAt(r); |
Use these rapid keyboard shortcuts to control the GitHub Atom text editor on Mac OSX.