Command line tools? In XXI century? No way! Yes way!

So, you just installed your PostgreSQL, and you have no idea how to use it – there is no icon in the menu of your OS, so how can you use it? Well, with the dreadful command line. Of course – some people will never get used to textual programs. They need a GUI. That’s … Continue reading “Command line tools? In XXI century? No way! Yes way!”

How I Learned to Stop Worrying and Love the Triggers

Some people are afraid of triggers. Reasons for this are not really understandable for me, but I guess it stems from the fact that these are usually application developers, and not database admins. Or they encountered some kind of problem with triggers, and now they tend to think that triggers are inherently evil. But they … Continue reading “How I Learned to Stop Worrying and Love the Triggers”

Getting top-N rows per group

Yesterday on irc someone asked: Hi, how do I get top 5 values from a column group by another column?? From further discussion, I learned that: total rows in table is 2 million. It’ll have unique words of less than 1 million.. (approx count) I didn’t have time yesterday, but decided to write a solution, … Continue reading “Getting top-N rows per group”

How to remove backups?

Question from title sounds weird to you? It’s just a ‘rm backup_filename’? Well. I really wish it was so simple in some cases. One of the servers I’m looking into, there is interesting situation: quite busy database server (2k tps is the low point of the day) very beefy hardware daily backups, each sized at … Continue reading “How to remove backups?”

Setting WAL Replication

There are several approaches on replication/failover – you might have heard of Slony, Londiste, pgPool and some other tools. WAL Replication is different from all of them in one aspect – it doesn’t let you query slave database (until 9.0, in which you actually can run read only queries on slave. Since you can’t run … Continue reading “Setting WAL Replication”