Added code to make use of David Walker's wonderfully abusive hack on thepg_proc table that showed me how to write recursive SQL functions. We nowhave good use of the index on tree_sortkey when climbing the tree, woo-hoo!
Oops - I'd previously committed a query with a literal substituted for:forum_id, done back when I was hacking these queries for greater efficiencyusing real test data. I was using psql so I was using literal values...