title: Why a SQL query is slower than another if according to EXPLAIN QUERY PLAN it should be the opposite?
body: <p>I have two tables</p>
  
  <pre><code>CREATE TABLE Categories (
     Category INTEGER,
     Id INTEGER,
     FOREIGN KEY (Category) REFERENCES CategoriesInfo(Category)
  )
  CREATE TABLE 'CategoriesInfo' (
     'Category' INTEGER PRIMARY KEY NOT NULL,
     'Name' TEXT
  )
  </code></pre>
  
  <p>with index</p>
  
  <pre><code>CREATE UNIQUE INDEX idxCategory ON Categories (Category, Id)
  </code></pre>
  
  <p>If I run </p>
  
  <pre><code>EXPLAIN QUERY PLAN
  SELECT CategoriesInfo.Category, Name
  FROM Categories, CategoriesInfo
  Where Categories.Category=CategoriesInfo.Category AND Id=:id
  ORDER BY Name
  </code></pre>
  
  <p>it says</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [selectid] =&gt; 0
              [order] =&gt; 0
              [from] =&gt; 1
              [detail] =&gt; SCAN TABLE CategoriesInfo (~1475 rows)
          )
  
      [1] =&gt; Array
          (
              [selectid] =&gt; 0
              [order] =&gt; 1
              [from] =&gt; 0
              [detail] =&gt; SEARCH TABLE Categories USING COVERING INDEX idxCategory (Category=? AND Id=?) (~1 rows)
          )
  
      [2] =&gt; Array
          (
              [selectid] =&gt; 0
              [order] =&gt; 0
              [from] =&gt; 0
              [detail] =&gt; USE TEMP B-TREE FOR ORDER BY
          )
  
  )
  </code></pre>
  
  <p>But if I use joins</p>
  
  <pre><code>EXPLAIN QUERY PLAN
  SELECT CategoriesInfo.Category, CategoriesInfo.Name
  FROM Categories
  LEFT JOIN CategoriesInfo ON (Categories.Category=CategoriesInfo.Category)
  WHERE Categories.Id=:id
  ORDER BY Name
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [selectid] =&gt; 0
              [order] =&gt; 0
              [from] =&gt; 0
              [detail] =&gt; SEARCH TABLE Categories USING AUTOMATIC COVERING INDEX (Id=?) (~6 rows)
          )
  
      [1] =&gt; Array
          (
              [selectid] =&gt; 0
              [order] =&gt; 1
              [from] =&gt; 1
              [detail] =&gt; SEARCH TABLE CategoriesInfo USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)
          )
  
      [2] =&gt; Array
          (
              [selectid] =&gt; 0
              [order] =&gt; 0
              [from] =&gt; 0
              [detail] =&gt; USE TEMP B-TREE FOR ORDER BY
          )
  
  )
  </code></pre>
  
  <p>Then, using joins should be faster. But when I run both codes with phpliteadmin,</p>
  
  <ul>
  <li>The 1st takes 0 seconds</li>
  <li>The 2nd takes 0.3281 seconds</li>
  </ul>
  
  <p>Why??</p>