![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, Just for general understanding, I have a question, related to how the rowid to index block lookup is done. This question was spawned by a 10046 trace that was run through the TraceAnalyzer (from Metalink, great tool) that showed me serious reads on an index that was not part of the access path from the optimizer plan, and I assume that this was to update this secondary index as a result of the update on the table. Consider this example: I have 2 indexes on a table, one the primary key PK, and another index, say A1 on an other field, for better access paths. (For this sample, the sanity of the design is another issue.) Now my update is done on this table using a data access path with PK. However in my trace report I also see the A1 index being read. That I understand, as the field's values are being changed and need to be reflected in the A1 index. Question: how does the oracle database engine effectively do the reverse lookup of the rowid that was given by the index PK, to the block of the index A1 that holds the entry for that rowid? |
#3
| |||
| |||
|
|
On 03/06/2010 05:02 PM, ErikYkema wrote: Hi, Question: how does the oracle database engine effectively do the reverse lookup of the rowid that was given by the index PK, to the block of the index A1 that holds the entry for that rowid? The most natural thing would be to use the old value of the field(s) that A1 indexes and do a regular index lookup. If the index is non unique ROWIDS of all entries for that key need to be checked additionally. What other ways could there be that would be equally efficient? |
#4
| |||
| |||
|
|
key value (as we see it) appear in the index ordered by rowid. So the same "binary chop" approach that Oracle uses to find a unique key allows it to find the specific rowid within the list of non-unique values very efficiently - it doesn't have to "check all entries" for the key. |
#5
| |||
| |||
|
|
Hi, Just for general understanding, I have a question, related to how the rowid to index block lookup is done. This question was spawned by a 10046 trace that was run through the TraceAnalyzer (from Metalink, great tool) that showed me serious reads on an index that was not part of the access path from the optimizer plan, and I assume that this was to update this secondary index as a result of the update on the table. Consider this example: I have 2 indexes on a table, one the primary key PK, and another index, say A1 on an other field, for better access paths. (For this sample, the sanity of the design is another issue.) Now my update is done on this table using a data access path with PK. However in my trace report I also see the A1 index being read. That I understand, as the field's values are being changed and need to be reflected in the A1 index. Question: how does the oracle database engine effectively do the reverse lookup of the rowid that was given by the index PK, to the block of the index A1 that holds the entry for that rowid? I hope the sample and question are clear, Thanks and best regards, Erik Ykema |
#6
| |||
| |||
|
|
"Robert Klemme"<shortcutter (AT) googlemail (DOT) com> wrote in message news:7vfeekF1s7U1 (AT) mid (DOT) individual.net... On 03/06/2010 05:02 PM, ErikYkema wrote: Hi, Question: how does the oracle database engine effectively do the reverse lookup of the rowid that was given by the index PK, to the block of the index A1 that holds the entry for that rowid? The most natural thing would be to use the old value of the field(s) that A1 indexes and do a regular index lookup. If the index is non unique ROWIDS of all entries for that key need to be checked additionally. What other ways could there be that would be equally efficient? That's basically it, but remember that the rowid becomes part of the index key if the index is unique. |
|
So we have (col1, col2) as our index, but internally the index is (col1, col2, rowid). This means that index entries for the same key value (as we see it) appear in the index ordered by rowid. So the same "binary chop" approach that Oracle uses to find a unique key allows it to find the specific rowid within the list of non-unique values very efficiently - it doesn't have to "check all entries" for the key. |
![]() |
| Thread Tools | |
| Display Modes | |
| |