Sunday 25 September 2011

Magic of window functions in PostgreSQL

Once I had an opportunity to provide a solution generating "everyday" statistic of game service usage by users perfectly presented by the maximum amount of game points each user had every 24 hours. The most convenient way to show that data anyone who concerns is a graphical chart showing variations of gained points within predefined ranges.

Historically the only raw data we had at the moment was the information of current number of points every time user is logged in.
The interesting part was that user does not log in every day and there was no way simple to present points flow for specified period as we wanted as there was likely to be a lot of zero values. The most suitable behaviour for this chart was to show last available value from the preceding days to fill the gaps. The easiest solution involving less coding and giving potential of reusing it in other services was PostgreSQL window functions.

Tuesday 13 September 2011

Awaiting of PostgreSQL 9.1 - short features review

Few weeks ago a PostgreSQL team announced the first release candidate of their powerful DBMS. It means that the release is going to be ready in several months. In the published release notes they have written following interesting information:
This release shows PostgreSQL moving beyond the traditional relational-database feature set with new, ground-breaking functionality that is unique to PostgreSQL.
From my point of view this is not just marketing words because every PostgreSQL major release always contained really  significant changes, which gives us high expectations for future releases as well. So, what are real advantages we might get from version 9.1 once it's released?