Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'll try an explanation... </p> <p><strong>eq_ref</strong> – imagine that you have two tables. Table A with columns (id, text) where id is a primary key. Table B with the same columns (id, text) where id is a primary key. Table A has the following data:</p> <pre><code>1, Hello 2, How are </code></pre> <p>Table B has the following data:</p> <pre><code>1, world! 2, you? </code></pre> <p>Imagine eq_ref as JOIN between A and B:</p> <pre><code>select A.text, B.text where A.ID = B.ID </code></pre> <p>This JOIN is very fast because for each row scanned in table A there can be only <strong>ONE</strong> row in table B which satisfies the JOIN condition. One and no more than one. That is because B.id is UNIQUE. Here you are a <em>pseudo</em> code which illustrates the processing at server side:</p> <pre><code>foreach (rowA in A) { if (existsInBRowWithID(rowA.id) { addToResult(rowA.text, getRowInBWithID(rowA.id).text); break; } } </code></pre> <p><strong>ref</strong> - Now imagine another table C with columns (id, text) in which id an index but a non UNIQUE one. Table C has the following data:</p> <pre><code>1, John! 1, Jack! </code></pre> <p>Imagine ref as JOIN between A and C:</p> <pre><code>select A.text, C.text where A.ID = C.ID </code></pre> <p>Here you are a pseudo code which illustrates the processing at server side:</p> <pre><code>foreach (rowA in A) { foreach (rowC in C) { if (rowA.id == rowC.id) { addToResult(rowA.text, rowC.text); } } } </code></pre> <p>This JOIN is NOT as fast as the former one because for each row scanned in table A there are <strong>SEVERAL</strong> possible rows in table C which may satisfy the JOIN condition (no break in the loop above). That is because C.ID is NOT UNIQUE.</p> <p>I hope that helps...</p> <p>Cheerz!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload