title: Fastest database design for keyword queries
body: <p>I am working on a Ruby on Rails site that is going to have a set of records that can be tagged with one or more keywords. Quite similar to the way questions on this site can be tagged with keywords.</p>
  
  <p>The Rails way to do this would be to have a many-to-many relationship between the records and the keywords. But I'm wondering if this join is going to slow down searches when there are lots of records.</p>
  
  <p>In particular, I'm going to need to do searches on multiple keywords, such as 'give me all the records that are tagged with keyword A, F, and G'. I'm not sure how well Rails would optimize this type of query.</p>
  
  <p>Any ideas on the best way to structure the models and/or controller for this type of app?</p>