title: PostgreSQL slow COUNT() - is trigger the only solution?
body: <p>I have a table with posts, which are categorized by:</p>
  
  <ul>
  <li>type</li>
  <li>tag</li>
  <li>language</li>
  </ul>
  
  <p>All of those "categories" are stored in next tables (posts_types) and connected via next tables (posts_types_assignment).</p>
  
  <p><a href="http://wiki.postgresql.org/wiki/Slow_Counting" rel="nofollow">COUNTing in PostgreSQL is really slow</a> (i have more than 500k records in that table) and i need to get the number of posts categorized by any combination of type/tag/lang.</p>
  
  <p>If i would solve it through triggers, it would be full of many multi-level loops, which really doesn't look like nice and is hard to maintenance.</p>
  
  <p>Is there any other solution how to effectively get actual number of posts categorized in any type/tag/language?</p>