The Build

11 March 2014

11:01

“The Worst Day of Your Life” at Nordic PostgreSQL Day 2014

I’ll be presenting “The Worst Day of Your Life” (dealing with major PostgreSQL disasters) at Nordic PostgreSQL Day 2014. My first trip to Scandinavia!

27 February 2014

12:35

“Really, Really Fast Django” at Djangocon EU

I’ll be presenting “Really, Really Fast Django” at Djangocon EU. Do come! It’s on a private island!

1 February 2014

10:41

“The Worst Day of Your Life” at FOSDEM PgDay 2014

FOSDEM PgDay 2014 was not, in fact, the worst day of my life; it was a great deal of fun. However, the slides from my presentation, The Worst Day of Your Life, dealing with PostgreSQL disasters, are now available.

28 January 2014

12:10

“JSON in PostgreSQL” at SCALE 12x

I’ll be presenting “JSON in PostgreSQL” at SCALE 12x in Los Angeles on Friday, February 21, 2014. Do come!

26 January 2014

18:09

“PostgreSQL Proficiency for Python People” at PyCon 2014

I’ll be giving a tutorial at PyCon 2014 in MontrĂ©al. Register early and often!

14 January 2014

11:25

django-pglocks 1.0.2 released

django-pglocks 1.0.2 has been pushed out. This fixes a bug that Aymeric Augustin found that keep a lock from being properly released. He also contributed a test framework to it… many thanks to him for that!

7 January 2014

14:51

Speaking at FOSDEM 2014

I’ll be speaking at FOSDEM 2014 in Brussels! I’ll be giving two talks:

1 December 2013

01:22

PostgreSQL Replication Bug

There’s a very unpleasant replication issue in version 9.0.14, 9.1.10, 9.2.5, 9.3.0 and 9.3.1 of PostgreSQL. Be sure to read the linked wiki entry carefully; it can result in silent data corruption on secondary servers in replication sets.

3 July 2013

08:18

JSON vs hstore: Which will get you into a cool bar in the Mission?

After all, isn’t that the most important issue?

Craig Kerstiens has a good overview of what the two types are. I wanted to give a quick and dirty flowchart as to which one I would use in a green-field development situation.

First, hstore performs better than JSON in nearly every situation, but performance is (as I wrote on Twitter) just one color in a rainbow of annoying decision points you have to make when building a system.

So, what would I do?

As JSON support in PostgreSQL matures, this calculus will change, perhaps significantly. But that’s the 9.2 situation, in my view.

2 July 2013

06:27

PostgreSQL Advisory Locks in Django Made Easy

Advisory locks are a very useful feature in PostgreSQL, and they just aren’t used enough.

Here’s a scenario: You have a bulk import job. While that job is running, there’s an analysis job you want to prevent from starting, and you don’t want a bulk import to start while the analysis job is running. But any number of bulk importers can run at the same time. How do you communicate this?

With an advisory lock!

Each of the bulk importers can take a shared advisory lock. Those locks don’t block each other, so they can run freely. But the analysis job takes an exclusive advisory lock of the same type. It will wait until all the importers are done, and the importers will not be issued their shared locks until it completes.

Even better, PostgreSQL cleans them up for you when a session terminates; you don’t have to worry about a lock lingering when you didn’t mean it to.

To make using advisory locks easier in Django, I have a small context manager than can be used to wrap code that should run with an advisory lock held; it makes it much easier to use them in your application. You can find it on GitHub, and it installs using pip.

« Older Entries