PDA

View Full Version : Specifying optimizer hints in JDBC


devage
02-20-03, 10:04
Hello,

When I submit a query using jdbc, that contains an optimizer hint, it behaves as if the hint is ignored.

I have supplied the hint as I would if I were submitting the query directly to the database, as follows:

SELECT /*+index(S_AGREE_ITEM S_AGREE_ITEM_X1) */ itm_stat_cd, ln_num FROM s_agree_item WHERE prod_int_ID = '2-7V-109' AND doc_agree_id = ''

The effect is the same if I use a Statement or a PreparedStatement.

Is there any special syntax or mechanism for supplying hints via jdbc?

This is making me crazy, if anyone can provide any clues I would really appreciate it.

Cheers,

Steve.

devage
02-21-03, 08:23
Hello... me again....

After MUCH investigation it turns out that JDBC (or the particular driver that I am using) prefixes the 'rowid' attribute to the list of attributes when sending a query.

It does this immediately after the SELECT statement, thereby rendering the optimizer hint unusable! I have put the query into an Oracle stored procedure instead and the hint is used as intended.

Hope this posting helps someone who comes across the same problem.

Cheers,

S.


Originally posted by devage
Hello,

When I submit a query using jdbc, that contains an optimizer hint, it behaves as if the hint is ignored.

I have supplied the hint as I would if I were submitting the query directly to the database, as follows:

SELECT /*+index(S_AGREE_ITEM S_AGREE_ITEM_X1) */ itm_stat_cd, ln_num FROM s_agree_item WHERE prod_int_ID = '2-7V-109' AND doc_agree_id = ''

The effect is the same if I use a Statement or a PreparedStatement.

Is there any special syntax or mechanism for supplying hints via jdbc?

This is making me crazy, if anyone can provide any clues I would really appreciate it.

Cheers,

Steve.