title: Fetching records with slug instead of ID
body: <p>I'm currently trying to find the best way (in term of usability and performance) when dealing with a situation like fetching records tagged with a specific tag, or category, or something like that.</p>
  
  <p>A good way (the way I wanted to do), would be to fetch records with the tag/category slug, so the URL would look like :</p>
  
  <pre><code>http://stackoverflow.com/questions/tagged/language-agnostic
  </code></pre>
  
  <p>fetching records by slug, which looks better than :</p>
  
  <pre><code>http://stackoverflow.com/questions/tag/789/language-agnostic
  </code></pre>
  
  <p>fetching by ID and adding the slug behind so it's more search-engine friendly. This one is better performance-wise, because fetching data by an integer ID would be faster than a string. (cmiiw)</p>
  
  <p>Now, with a db schema like :</p>
  
  <pre><code>posts    post_to_tags    tags
  -----    ------------    ----
  id       id              id
  title    post_id         name
  content  tag_id          slug
  ...                      ...
  </code></pre>
  
  <p>am I doing it right ? Is there pitfall or best-practices that I need to know to avoid performance problems ? (eg. tags should not exceed 10,000 records, or tag slug should not exceed n characters, or something else)</p>
  
  <p>Thanks in advance.</p>