87 Articles tagged “YeSQL”

Window Functions example

So, when 8.4 came out there was all those comments about how getting window functions was an awesome addition. Now, it seems that a lot of people seeking for help in #postgresql just don’t know what kind of problem this feature helps solving. I’ve already been using them in some cases here in this blog, for getting some nice overview about Partitioning: relation size per “group”. *That's another way to count change* Now, another example use case rose on IRC today.



Happy Numbers

After discovering the excellent Gwene service, which allows you to subscribe to newsgroups to read RSS content ( blogs, planets, commits, etc), I came to read this nice article about Happy Numbers. That’s a little problem that fits well an interview style question, so I first solved it yesterday evening in Emacs Lisp as that’s the language I use the most those days. A happy number is defined by the following process.


Playing with bit strings

The idea of the day ain’t directly from me, I’m just helping with a very thin subpart of the problem. The problem, I can’t say much about, let’s just assume you want to reduce the storage of MD5 in your database, so you want to abuse bit strings. A solution to use them works fine, but the datatype is still missing some facilities, for example going from and to hexadecimal representation in text.


This time, we are trying to figure out where is the bulk of the data on disk. The trick is that we’re using DDL partitioning, but we want a “nice” view of size per partition set. Meaning that if you have for example a parent table foo with partitions foo_201006 and foo_201007, you would want to see a single category foo containing the accumulated size of all the partitions underneath foo.


Finding orphaned sequences

This time we’re having a database where sequences were used, but not systematically as a default value of a given column. It’s mainly an historic bad idea, but you know the usual excuse with bad ideas and bad code: the first 6 months it’s experimental, after that it’s historic. *Not talking about genome orphaned sequences here, though* Still, here’s a query for 8.4 that will allow you to list those sequences you have that are not used as a default value in any of your tables:

Dimitri Fontaine

PostgreSQL Major Contributor

Open Source Software Engineer

France