Thursday, May 30, 2013

Review of "Instant PostgreSQL Starter"

This is my review of "Instant PostgreSQL Starter" by Daniel K. Lyons.

Packt publishing asked me to review "Instant PostgreSQL Starter" after I won a copy of "Instant PostgreSQL Backup and Restore How-to" through Hubert "depesz" Lubaczewski's blog. I am posting this three or four days later than agreed upon but family comes first.

To be totally honest, I am not really the target audience for this book. I started with MySQL back in 2002 and moved on Oracle in 2005. I have been using PostgreSQL for about a year now and feel quite comfortable with all of the basics and many of the advanced features already.

The book starts out with an introduction that briefly mentions what will be covered. The first chapter explains why you want to use PostgreSQL, summarizes what a database is and how readers with various levels of experience can draw upon their existing knowledge while learning PostgreSQL.

The second chapter covers installation and set up. The first three sections of this chapter explain what you need before you start, how to download and install PostgreSQL. The section on downloading starts out by saying, "There are many ways to get PostgreSQL installed on your computer"; however, it only tells you where to find the latest installation packages from EnterpriseDB and how to install them. The EnterpriseDB packages are top-notch and make it super simple for anyone to install PostgreSQL so I fully understand why it was included. That said, I am a big fan of compiling from source code, because I prefer to end up with all of the features I need and nothing else, so I was disappointed to find that doing so was not even mentioned in passing. The following two sections of this chapter tell you how to connect to PostgreSQL, create a user and a database with pgAdmin. I expected these topics to be done graphically so I was quite surprised to find that after you have connected, you are shown what SQL to use to accomplish the rest of these tasks. I was a little disappointed, but at this point not surprised, to find that psql was not mentioned.

The third chapter discusses some SQL basics such as how to create your first table, populate it with data using INSERT, query the table using SELECT as well how to UPDATE or DELETE rows. If you are new to databases, you will learn quite a bit in a short period of time. For example, the CREATE TABLE section introduces some new concepts such as Data Definition Language, column type (VARCHAR), constraint (NOT NULL), primary key, and modifiers (DEFAULT). It was quite thoughtful for the single quote gotcha to be called out in the INSERT section.

The fourth chapter talks about nine PostgreSQL features that the author felt that everyone needs to know about:

  • the pgcrypto extension and how to use it to create passwords that you can use in your application
  • why and how you can use the RETURNING clause
  • some basics about the hstore extension
  • the XML type and how you might use it to store HTML (JSON gets a brief sidebar here but I would have preferred it get the same level of attention)
  • recursive queries and common table expressions (CTE)
  • full-text search with a reasonable level of detail including the various index types you would use
  • how you can use pgAdmin for backup and restore as well a quick summary of how to do those from the command line as well
  • how to determine the size of your tables with and without indexes
  • using EXPLAIN ANALYSE to see what query plan was used for a query
I have no idea why this chapter only shows nine features or why these particular ones were chosen over others but it gives you a broad understanding of what you can do with PostgreSQL.

The fifth and final chapter briefly covers the documentation, community wiki, mailing lists, websites and even Twitter.

I feel that this is a great introduction to PostgreSQL for someone with little or no database experience. As the publisher's page says, this book is intended to be "[a] short, fast, focused guide" and it certainly lives up to that description.