Tips N’ Tricks – getting sizes of relations without locks

If you have production DB servers, chances are you're running variant of these queries:

SELECT SUM(pg_relation_size(oid)) FROM pg_class WHERE relkind = 'i'
SELECT SUM(pg_relation_size(oid)) FROM pg_class WHERE relkind = 'r'

To get summarized size of tables and/or indexes in your database (for example for graphing purposes).

This (getting pg_relation_size for rows in pg_class) has one problem – it can lock, or it can fail.

Continue reading Tips N' Tricks – getting sizes of relations without locks

r/trees ( recursive trees, what did you think about? )

I got asked on irc to show some examples how to use recursive CTE. Apparently my previous post wasn't good enough 🙂

I think that most of the users will use recursive cte to deal with trees I decided to show how to use it, even though it's not my favorite approach to dealing with trees in SQL.

Continue reading r/trees ( recursive trees, what did you think about? )

Waiting for 9.2 – excluding data of table from dump

On 14h of December, Andrew Dunstan committed patch:

Add --exclude-table-data option to pg_dump.
 
Andrew Dunstan, reviewed by Josh Berkus, Robert Haas and Peter Geoghegan.
 
This allows dumping of a table definition but not its data, on a per table basis.
Table name patterns are supported just as for --exclude-table.

Continue reading Waiting for 9.2 – excluding data of table from dump

Louis CK – live at the Beacon Theater

I'm huge fan of stand-up comedy, and one of the guys that I like is Louis CK. Learned today that he made new movie – “Live at the Beacon Theater", and it's available on his site. For $5. Without DRM, geographical limitations or other bullshit.

So, if you can handle his kind of jokes – it's a must have. And at this price (again: 5 USD!) it's not like your budget will collapse.

The site is https://buy.louisck.net/, and there is also interesting statement explaining some things, and telling how much did he made so far.

Apparently there are some DNS issues with their site – it the name doesn't resolve, either switch (temporarily) to 8.8.8.8 dns server, or use following information to fill your /etc/hosts:

$ host buy.louisck.net
buy.louisck.net is an alias for LiveSiteELB-1109051832.us-east-1.elb.amazonaws.com.
LiveSiteELB-1109051832.us-east-1.elb.amazonaws.com has address 107.21.105.222
LiveSiteELB-1109051832.us-east-1.elb.amazonaws.com has address 107.21.113.172
LiveSiteELB-1109051832.us-east-1.elb.amazonaws.com has address 107.22.233.77
LiveSiteELB-1109051832.us-east-1.elb.amazonaws.com has address 107.21.103.188
LiveSiteELB-1109051832.us-east-1.elb.amazonaws.com has address 107.21.105.96
LiveSiteELB-1109051832.us-east-1.elb.amazonaws.com has address 107.21.105.220