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.
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.
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.
Any ideas on the best way to structure the models and/or controller for this type of app?
While a typical foriegn key relationship between records and keywords (tags) can work pretty well as a storage structure; if you are so concerned about faster access to the same why not add a caching layer like
memcachedto your application: Adds to the program complexity but is known to give significant performance benefits forreadoperations.