Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Putting the indexes in will help queries partly if it leads directly to the correct result, but also can give great benefits if it improves locality of reference and reduces the amount of memory read.</p> <p>For the question as asked, the answer is "it depends". It depends on your queries. If there is one major column queried, which always appears in the search, e.g. <code>INT1</code>, create an index on:</p> <pre><code> unique (INT1, INT2, INT3, REF) </code></pre> <p>Then any query referencing INT1 and any combination of the other fields will be quick.</p> <p>Also, any query referencing INT2 but not INt1 will also benefit because the whole table doesn't need to be read - only the index. Even though INT2 is not at the head of the index, the query still benefits: the DB will skip over INT1 and just look at INT2, but it can get a view of the table INT2 values, without having to read the whole table.</p> <p>So really you need to better understand the queries which will be done. If one column ALWAYS appears, put that at the head of an index. If another column OFTEN appears, that should be number 2. </p> <p>If there are two columns which both often appear, you can do this:</p> <pre><code>unique (INT1, INT2, INT3, REF), unique (INT2, INT1, INT3, REF) </code></pre> <p>Then we would hope that if INT1 is not specified, but INT2 is specified, the second index will be used.</p> <p>Don't use too many indexes though, they can take up a lot of disk space.</p> <p><strong>Bottom Line:</strong> Test the queries with and without the indexes. You need to collect 10-20 minimum sample queries, and test their IO and clock times. That is the only way to get a true answer.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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