Problem
A DBA of mine recently told me that NULLs would not end up in indexes, that is if the index is a single column index. Likewise, an entry in compound indexes is omitted if all the columns are NULL. The implication seems to be that if your where clause asks for the presence of NULL, Oracle cannot use an index because the information whether an attribute is NULL or not is not known to the index.
That means that the record in the index is missing. The logic behind that it seems, that if we do not know the value we have no statement at all.
To me, this is quite bullshit.
- If I ask someone how much money is on his bank account and he answers he does not know it is a difference to if he does not answer at all. If the "We do not know" was a neglectable statement, I dare say, the SQL standard would not define expression like "IS NULL".
- To omit a record in the index if all NULL is not consistent to a tables getting a record if all columns are NULL.
Workaround
- Use only compound indexes with at least one not-nullable column, possibly as last column as inert weight.
- Use possibly function based indexes
Keine Kommentare:
Kommentar veröffentlichen