Permalink
Browse files

Add some note on adding index to HABTM table

  • Loading branch information...
1 parent d64e095 commit f0be2cb19274bb6029f84ca274a72c4d7fbee2d3 @sikachu sikachu committed Oct 20, 2011
Showing with 4 additions and 0 deletions.
  1. +4 −0 activerecord/lib/active_record/associations.rb
@@ -1432,6 +1432,10 @@ def belongs_to(name, options = {})
# end
# end
#
+ # It's also a good idea to add indexes to each of those columns to speed up the joins process.
+ # However, in MySQL it is advised to add a compound index for both of the columns as MySQL only
+ # uses one index per table during the lookup.
+ #
# Adds the following methods for retrieval and query:
#
# [collection(force_reload = false)]

0 comments on commit f0be2cb

Please sign in to comment.