I have a question regarding some of the results we got from the optimisation.
We are on Oracle 9i and use Toad version 9.0.1.8.
The query is very simple. The original query was:
select t.transaction_id,
t.transaction_id_reversed,
t.tran_status_code,
t.branch_id
from jbs_transaction t
where t.tran_status_code = ‘U’ and
t.transaction_id_reversed is not null
execution time is 9 seconds.
After running the query through optimiser it came with following options (among others):
select /*+ INDEX_JOIN(T) */ t.transaction_id,
t.transaction_id_reversed,
t.tran_status_code,
t.branch_id
from jbs_transaction t
where t.tran_status_code = ‘U’
and t.transaction_id_reversed is not null
this one took 2 seconds to complete
and one more:
select /*+ FIRST_ROWS */ t.transaction_id,
t.transaction_id_reversed,
t.tran_status_code,
t.branch_id
from jbs_transaction t
where ‘U’ = t.tran_status_code
AND 1E28 >= -t.transaction_id_reversed
this one takes only 16 ms.
The hint on its own does not give the performance improvement.
select /*+ FIRST_ROWS */ t.transaction_id,
t.transaction_id_reversed,
t.tran_status_code,
t.branch_id
from jbs_transaction t
where ‘U’ = t.tran_status_code
AND t.transaction_id_reversed is not null
takes 1:05 minutes.
Using just the magic number without the hint takes 11 seconds.
At the same time for some reason the optimiser did not come with
the suggestion to use:
select /*+ INDEX(T TRAN_TRANSTS_FK_I) */ t.transaction_id,
t.transaction_id_reversed,
t.tran_status_code,
t.branch_id
from jbs_transaction t
where t.tran_status_code = ‘U’
and t.transaction_id_reversed is not null
This takes 15 ms.
The index TRAN_TRANSTS_FK_I is defined
as not unique index on the column TRAN_STATUS_CODE, Asc.
The questions I have:
-
Why the optimiser did not consider using the TRAN_TRANSTS_FK_I, is there a setting we should switch on or change for the optimiser to try using the indexes?
-
What is the magic number 1E28 and is this something which can be reliably used to check for null of a column and does it only work with the FIRST_ROWS hint? I could not find any information about this. Will it still work on the next version of Oracle.
The column transaction_id_reversed is defined as NUMBER(28).
Than you very much.