title: Why is doing a top(1) on an indexed column in SQL Server slow?
body: <p>I'm puzzled by the following. I have a DB with around 10 million rows, and (among other indices) on 1 column (campaignid_int) is an index.</p>
  
  <p>Now I have 700k rows where the campaignid is indeed 3835</p>
  
  <p>For all these rows, the connectionid is the same.</p>
  
  <p>I just want to find out this connectionid.</p>
  
  <pre><code> use messaging_db;
   SELECT     TOP (1) connectionid
   FROM         outgoing_messages WITH (NOLOCK)
   WHERE     (campaignid_int = 3835)
  </code></pre>
  
  <p>Now this query takes approx 30 seconds to perform!</p>
  
  <p>I (with my small db knowledge) would expect that it would take any of the rows, and return me that connectionid</p>
  
  <p>If I test this same query for a campaign which only has 1 entry, it goes really fast. So the index works.</p>
  
  <p>How would I tackle this and why does this not work?</p>
  
  <p>edit:</p>
  
  <pre><code>estimated execution plan:
  
  select (0%) - top (0%) - clustered index scan (100%)
  </code></pre>