We have a Rails3 application where we just started development. We use the has_and_belongs_to_many relationship between the two models. Each time we use one of these models, ActiveRecord executes a DESCRIBE query in the connection table, for example:
SQL (1.1ms) describe `articles_tags`
These queries are relatively expensive (that is, more than 10 times slower than the actual SELECT query) and are executed very often. This does not seem to me necessary: the table was automatically generated due to the has_and_belongs_to_many relationship, so ActiveRecord should already know about its structure (just the column article_id and tag_id).
Is there a good reason for this behavior? If not, how can I stop him?
source
share