title: Clickhouse join with condition
body: <p>I found strange thing, the query:</p>
  <pre><code>SELECT *
  FROM progress as pp
  ALL LEFT JOIN links as ll USING (viewId)
  WHERE viewId = 'a776a2f2-16ad-448a-858d-891e68bec9a8' 
  </code></pre>
  <p>Result: <code>0 rows in set. Elapsed: 5.267 sec. Processed 8.62 million rows, 484.94 MB (1.64 million rows/s., 92.08 MB/s.)</code></p>
  <p>Here modified query:</p>
  <pre><code>SELECT *
  FROM
    (SELECT *
     FROM progress
     WHERE viewId = 'a776a2f2-16ad-448a-858d-891e68bec9a8') AS p ALL
  LEFT JOIN
    (SELECT *
     FROM links
     WHERE viewId = toUUID('a776a2f2-16ad-448a-858d-891e68bec9a8')) AS l ON p.viewId = l.viewId;
  </code></pre>
  <p>Result : <code>0 rows in set. Elapsed: 0.076 sec. Processed 4.48 million rows, 161.35 MB (58.69 million rows/s., 2.12 GB/s.) </code></p>
  <p>But it looks dirty.</p>
  <p>Isn't it supposed to optimize the query considering where condition?</p>
  <p>What is the right way to write the query here, and what if it will be where in?</p>
  <p>Then I try to add another join:</p>
  <pre><code>SELECT *
  FROM
    (SELECT videoUuid AS contentUuid,
            viewId
     FROM
       (SELECT *
        FROM progress
        WHERE viewId = 'a776a2f2-16ad-448a-858d-891e68bec9a8') p ALL
     LEFT JOIN
       (SELECT *
        FROM links
        WHERE viewId = toUUID('a776a2f2-16ad-448a-858d-891e68bec9a8')) USING `viewId`) ALL
  LEFT JOIN `metaInfo` USING `viewId`,
                             `contentUuid`;
  </code></pre>
  <p>The result again very slow, considering that I want just join 3 tables with condition selection one row:</p>
  <p><code>0 rows in set. Elapsed: 1.747 sec. Processed 9.13 million rows, 726.55 MB (5.22 million rows/s., 415.85 MB/s.) </code></p>