title: MySQL: Unique constrain multiple columns performance optimization
body: <p>I see tons of questions about unique constrains on multiple questions but none that match what I am specifically looking for.  If this is a duplicate of one, I apologies.</p>
  
  <p>I have a table that is just:
  tableA_id
  tableB_id</p>
  
  <p>My primary key is a unique constraint on both tables, and i have a index on both columns.  Both are also primary keys to their respected tables.</p>
  
  <p>If tableA is likely to have say 10,000,000 rows and table B to have say 2,000,000 rows, it is more likely that TableB will be in this constraint far less times.  That being sad, is it more optimized when I am making my unique constraint to put TableB as the first column since there are less to search for, TableA (if so why), or it makes no difference as it does not search one first then the other, rather goes 1 by one looking at both.</p>
  
  <p>Thanks in advance</p>