title: How to implement tagging system similar to SO in php/mysql?
body: <p>I'm coding a website in PHP/MySQL and I'd like to implement a similar to stackoverflow tagging engine. I have 3 relevant tables in DB:
  1. Items
  2. Tags
  3. ItemTagMap (maps tags to items, n:n mapping)</p>
  
  <p>Now, on search page I'd like to show distinct list of all tags for entire search result (not just the current page), so that users can "refine" their search by adding/removing tags from that tag list.</p>
  
  <p>The question is that it's a pretty heavy query on the DB and there can be tons of search requests that result in different result sets and thus different tag sets.</p>
  
  <p>Does anyone know how to implement this effectively?</p>