Introduction to Hacking PostgreSQL
Gavin Sherry and I have presented several versions of a tutorial introduction
on how to modify the PostgreSQL source code. The original version was given at
the PostgreSQL Anniversary Summit in June of 2006. Gavin has since given a
revised version of the talk (at LCA 2007), as have I (at PgCon 2007).
All three versions of the talk follow a similar format: the first 90 minutes
provid a general introduction to the backend, common coding conventions, and
the procedure that is typically followed for submitting a new patch. The second
90 minutes walk the audience through an example patch.
Ottawa (PgCon 2007)
- Presentation slides
- Handout with excerpts from patch
- Complete example patch implementing the
TABLESAMPLE clause (context diff against the CVS HEAD code as of
May 19, 2007)
- Excerpts from the SQL standard for the
Australia (LCA 2007)
Gavin presented an updated version of this tutorial at the PostgreSQL mini-conf that
preceded LCA 2007. The slides and handouts
for that talk are available.
Toronto (Anniversary Summit, 2006)
- Presentation Slides
- An example patch that adds support for the WHEN clause to
the CREATE TRIGGER statement
- Handout of notable sections of code from the example patch;
when the slides include statement like “see page n“, they are referring to pages from
I’ve given two other talks on PostgreSQL internals:
- “Inside the PostgreSQL Query Optimizer” describes how the optimizer works (as of April 2005). It is slightly out of date with respect to a few details, but is still mostly accurate.
- “Query Evaluation Techniques in PostgreSQL” discusses the algorithms for implementing scans, joins, and aggregation used in PostgreSQL (as of October 2007).
Tom Lane gave a great talk on “recent” improvements to the PostgreSQL query
optimizer in 2003. Despite being slightly dated, it is still
- October 31, 2007: Added links to other talks on Postgres internals, added some new content to the Ottawa slides.
- May 21, 2007: Added Ottawa version of the talk.
- May 9, 2007: Linked to Gavin’s modified LCA talk.
- July 11, 2006: Initial version posted.
- July 21, 2006: Made various minor corrections to the slides. Added email addresses for Gavin and myself.