title: ClickHouse MergeTree slow SELECT with ORDER BY
body: <p>I'm starting to learn CH and seem to be running into dead ends while trying to improve my query speed, the table is created like this</p>
  
  <pre class="lang-sql prettyprint-override"><code>CREATE TABLE default.stats(
    aa String, 
    ab String, 
    user_id UInt16, 
    ac UInt32,  
    ad UInt8, 
    ae UInt8, 
    created_time DateTime, 
    created_date Date, 
    af UInt8, 
    ag UInt32, 
    ah UInt32, 
    ai String, 
    aj String) 
  ENGINE = MergeTree 
  PARTITION BY toYYYYMM(created_time) 
  ORDER BY(created_time, user_id)
  </code></pre>
  
  <p>and I'm running a query like so</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT ad, created_time, ab, aa, user_id, ac, ag, af 
  FROM stats 
  WHERE user_id = 1 AND lowerUTF8(ab) = 'xxxxxxxxx' AND ad != 12 
  ORDER BY created_time DESC 
  LIMIT 50 OFFSET 0
  </code></pre>
  
  <p>this is the result <strong>50 rows in set. Elapsed: 2.881 sec. Processed 74.62 million rows</strong></p>
  
  <p>and if I run the same query without the order part, <strong>50 rows in set. Elapsed: 0.020 sec. Processed 49.15 thousand rows</strong></p>
  
  <p>Why does it seem to process all the rows in the table if in theory the query only has to order around 10k(all the rows returned without the limit) rows? What am I missing and/or how could I improve the speed of CH?</p>