title: Order of comparison in composite UNIQUE constraint in MS SQL
body: <p>I'm designing a database and have come across a performance related problem. Please note that we are still in the phase of designing not implementing so I can't test anything yet.</p>
  
  <p>I have the following table structure</p>
  
  <pre><code>Events
  ----------------------
  EventID      INT    PK
  SourceID     INT    FK
  TypeID       INT    FK
  Date         DATETIME
  </code></pre>
  
  <p>The table is expected to contain tens of millions of entries. <code>SourceID</code> and <code>TypeID</code> both reference tables with at most hundreds of entries.
  What I want is to have the tuple <code>(SourceID, TypeID, Date)</code> unique across the table. The question is: can I somehow specify which of the three columns will be used as the first to determine uniqueness when I would insert a new item in the table?
  Because if the index compared the <code>Date</code> first, then the addition would be much faster, than if it for example used <code>TypeID</code> first, right? Or is this a wrong question altogether and I should trust the SQL server to optimize this itself?</p>
  
  <p>Any feedback is appreciated.</p>