title: mysql vs sqlserver vs postgres Do they store indexes differently?
body: <p>I am currently benchmarking the three DBs for a special use case.</p>
  
  <p>tabledata (10,000,000 rows)</p>
  
  <pre><code>id, facebook[random int 0-1,000,000], youtube[random int 0-1,000,000]
  1, 322342, 293492
  2, ...
  </code></pre>
  
  <p>6 queries:</p>
  
  <pre><code>SELECT youtube, facebook FROM file_results WHERE youtube &gt; 500000 AND facebook &gt; 500000 ORDER BY youtube DESC LIMIT 100
  SELECT youtube, facebook, youtube+facebook as total FROM file_results WHERE facebook+youtube &gt; 1000000 ORDER BY youtube DESC LIMIT 100
  SELECT youtube, facebook, youtube+facebook as total FROM file_results WHERE facebook &gt; 500000 AND youtube &gt; 500000 ORDER BY facebook+youtube DESC LIMIT 100
  SELECT youtube, facebook, youtube+facebook as total FROM file_results WHERE facebook &gt; 900000 AND youtube &gt; 900000 ORDER BY facebook+youtube DESC LIMIT 100
  SELECT youtube, facebook, youtube+facebook as total FROM file_results WHERE facebook+youtube &gt; 1000000 ORDER BY facebook+youtube DESC LIMIT 100
  SELECT youtube, facebook, youtube+facebook as total FROM file_results WHERE facebook+youtube &gt; 1800000 ORDER BY facebook+youtube DESC LIMIT 100
  </code></pre>
  
  <p>6 results (ms):</p>
  
  <p><a href="https://i.stack.imgur.com/Vr2n8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vr2n8.png" alt="enter image description here"></a></p>
  
  <p>As you can see, mysql is very fast when returning data that part of existing indexes (facebook and youtube are both indexed). However the db timing rankings reverse when more complex queries are used that order by something that is not directly indexed (e.g. the sum of two columns). I think I recall that some DBs store the data directly in the indexes while other use a pointer to the actual data. Might this be the case</p>