Posts I Like
Who I Follow

thoughtbot:

As it turns out, PostgreSQL has a number of ways of storing loosely structured data — documents — in a column on a table.

  • hstore is a data type available as a contrib package that allows you to store key/value structures just like a dictionary or hash.
  • You can store data in JSON format on…

thoughtbot:

It’s right there in the docs but I didn’t notice it until recently:

heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote staging

Boom! It transfers the production Postgres database to staging.

It’s much faster than db:pull, then db:push, which is what I…

To view your session specific local modifications when tuning your Postgres database &  ’\x on’ prints out your query in a readable format:

psql

\x on

select * from pg_settings

Here are some resources for us non-CS majors who became programmers anyway:

Big O:

http://www.perlmonks.org/?node_id=227909

https://www.youtube.com/watch?v=V6mKVRU1evU

Basic Search Algorithms:

http://algorithms.openmymind.net/

http://interactivepython.org/runestone/static/pythonds/index.html

I will add resources as I come upon them and feel free to add yours in the notes and I’ll add them to the post.

So I was following some advice from one of the tutorials I took at PyCon2014 called Postgres for Python People and since it was more of a list of stuff you should implement when using Postgres rather than a hands on tutorial, I thought I’d better get to it a month later.  I have Postgres installed via Hombrew on my Mac and realized there was no folder for my log files, it’s just plopped in under the Postgres folder:  /usr/local/var/postgres/server.log

So I created a pg_log folder under /usr/local/var/postgres/

then changed my homebrew.mxcl.postgresql.plist (which is a simple xml file) to point to the pg_log folder:

<key>StandardErrorPath</key>
<string>/usr/local/var/postgres/pg_log/server.log</string>

Then I shut down the Postgres server via launchctl:

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Then restarted it again via launchctl:

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

And now your server.log files are under pg_log folder!

If you don’t want to sort through a long blog post on grep flags and simply want a more interactive solution, you won’t get any help by typing (bad pun intended):

grep —help

or any other combo of help in the command line. So, I recently learned that you use:

man grep

and that will give you all the dirty on grep in a very readable format.  SO next time you’re typing in something like:

ps auxw | grep postgres | grep — -D

and want to know what the heck the -D flag is for just man grep and you’ll find out this: -D action—devices=action

man grep

Specify the demanded action for devices, FIFOs and sockets.  The default action is `read’, which means, that they are read as if they were normal files.  If the action is set to `skip’, devices will be silently skipped.

A couple of nice resources when you haven’t installed Postgres via the EnterpriseDB installer and you are wondering where your postgres.plist is and where the heck your logs are.

https://wiki.postgresql.org/wiki/Installers/Mac_OS_X

http://stackoverflow.com/questions/2563494/where-postgresql-logs-are-on-mac-os-x