Some developer said that the column that has more different values DOCUMENT_CODE must be the first in the index
This is total fiction, and has been a myth in the oracle community for decades. The number of distinct values in the column plays no role in where that column sits in the index. (I'll come back to this point shortly)
You choose the order of index columns based on the benefit they will have the application SQL code. For example, if your app does queries like:
where a =
and b =
and c =
where b =
and c =
where c =
Then I would add an index with columns as (c,b,a) because than all three queries can potentially get some benefit, whereas an index (a,b,c) only helps with the first, (b,c,a) only helps with 2 of them etc. Choose the column order based on the best overall benefit.
Now..what if your application only does:
where a =
and b =
The question then is: should it be (a,b) or (b,a).
Typically the better option will be to choose the column with the LEAST number of distinct values to go first, because then you can use the (free) basic index compression, eg, if 'a' has the most repeated values (ie, least distinct values) then
create index ... on .... (a,b) compress 1
yields a smaller, more dense index which makes it more efficient to use.