Each major release of PostgreSQL brings lots of great new functionality. The recent release of PostgreSQL 9.4 includes an exciting new JSON data type, improvements to window functions, materialized views, and a host of other performance improvements and enhancements. We’ll go into more depth on what’s new and exciting in this release below, but first, we want you to know that Postgres 9.4 is available in beta right now on Heroku:
$ heroku addons:add heroku-postgresql --version=9.4
Because the safety and reliability of your data is incredibly important to us, we’re launching 9.4 support in a beta state. This means that customers looking to follow the bleeding edge and get the first access to new features can get started with Postgres 9.4 right now. Customers who are content with what they have right now should continue to use 9.3 for new databases until 9.4 matures and we make support generally available.
Postgres combines the performance and flexibility of a modern document store with the kind of durability and power found in a more traditional RDBMS. Indeed, Postgres has offered native support for JSON for several years now. With each release, that support has seen significant improvements. The 9.3 release introduced JSON operators that allow JSON subdocuments to be queried. This release builds on that work by revising the underlying storage of JSON data to a more efficient binary format.
The new JSONB data type (the "b" stands for binary) brings significant performance improvements. Previously, JSON data was stored as raw text that required re-parsing with every access. The new JSONB format looks and feels just like normal JSON to the user, but it is parsed only once (on insert) after which it is stored in a specialized binary format. This makes querying and processing much faster.
Most exciting, JSONB supports GIN indexes. These indexes provide a "universal" index, which allows you to efficiently execute a wide variety of queries. This is in contrast to other databases which require a separate index to be manually created for each query you want to optimize. You can:
CREATE INDEX idx_users_preferences ON users USING gin (preferences);
There are a number of other noteworthy improvements:
Refreshing a materialized view can be performed without blocking reads to it.
As described above, Heroku currently supports Postgres 9.4 as a beta. We encourage users to wait for GA before adopting 9.4 for production applications, and new databases are not provisioned with 9.4 by default, but only with the --version flag. All databases provisioned with Postgres 9.4 are billed at our standard prices and Postgres 9.4 is available on all plans.
Once we feel confident that Postgres 9.4 is stable - based on both Heroku customers’ experience as well as monitoring community discussions - we will make it available in GA and promote it to become the new default. In keeping with our versioning policy of maintaining three major releases, some time after Postgres 9.4 becomes the default, Postgres 9.1 will be deprecated.
Postgres 9.4 is an exciting release, and we hope that this early opportunity to use it in beta will encourage you to start taking advantage of its features immediately. This new release is shaped in part by you! We take all the great feedback and input from our users and use that to help drive our contributions to Postgres each year. In fact, several of the new features in 9.4 were contributed by our team and inspired directly by your needs.
As usual, every Heroku Postgres database comes with additional features according to its plan, including dataclips, performance analytics, pg:diagnose and encryption at rest. We will continue to invest in making your applications a success on Heroku Postgres by adding new features, tuning your database performance, improving visibility, safeguarding your data and keeping your database running so you can sleep well at night.