Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Actually there can be a decrease in performance when you drop the index on the single column.</p> <p>Suppose you do a query with <code>WHERE [Column1] = 123</code>. This could be solved perfectly with the original index. The new index can also be used for this but will -depending on the implementation- need to read the values for [Column2] in the index as well even though they are not used.</p> <p>So yes: there can in theory be a downside to dropping the index: increased reads.</p> <p>[Update 9 sept.]<br> Recently I encountered another situation where a single index can be <strong>much better</strong> than a combined index.<br> Consider a huge table 'bugs' with column [status], [createdate] and some other fields. Most bugs will be closed so assume status is '0' (open) for 100 records and '1' (closed) for 99000 records.</p> <p><code>SELECT * FROM bugs WHERE status = '0'</code> will benefit enormously from an index on <code>status</code> whereas with <code>SELECT * FROM bugs WHERE status = '1'</code> an index on <code>status</code> will not help.</p> <p>Oracle will know the difference because it builds statistics on the index.</p> <p>However, with an combined index on <code>status, createdate</code> each index entry is almost unique and Oracle will decide not to use the index for the query <code>SELECT * FROM bugs WHERE status = '0'</code> because it guesses (wrongly) that the index would not help.</p> <p>So in this situation a single index should not be dropped just because it is a prefix to a combined index.</p> <p>Note: In theory Oracle could build even smarter statistics on the index but it does not seem to do that.</p>
    singulars
    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.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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