Thanks for the question, naren.
Asked: November 03, 2016 - 2:31 am UTC
Last updated: November 17, 2016 - 2:29 am UTC
Version: 12.1.0.2
Viewed 10K+ times! This question is
You Asked
Hi Tom,
I have one query that is running for a really long time. I was playing with the ordered hint and I noticed that SQL performs much better..I am not sure why though. Can you please explain a scenario where ordered or leading hint will actually help?
below is my SQL:
SELECT /*+ ORDERED */
PO.po_number,
PO.po_header_id,
GCC.concatenated_segments,
GCC.segment1,
GCC.segment2,
GCC.segment3,
GCC.segment4,
GCC.segment5,
GCC.segment6,
GCC.segment7,
NVL (GJL.entered_dr, 0) - NVL (GJL.entered_cr, 0)
FROM UP_PO_ENCUMB_RELIEF_PO2_STG PO,
xla.xla_transaction_entities XTE,
apps.xla_ae_headers XAH,
apps.xla_ae_lines XAL,
apps.gl_import_references GIR,
gl_je_lines GJL,
gl_je_headers GJH,
gl_code_combinations_kfv GCC
WHERE XTE.application_id = 201
AND XTE.source_id_int_1 = PO.po_header_id
AND XAH.application_id = XTE.application_id
AND XAH.entity_id = XTE.entity_id
AND XAL.application_id = XAH.application_id
AND XAL.ae_header_id = XAH.ae_header_id
AND GIR.gl_sl_link_id = XAL.gl_sl_link_id
AND GIR.gl_sl_link_table = XAL.gl_sl_link_table
AND GJL.je_header_id = GIR.je_header_id
AND GJL.je_line_num = GIR.je_line_num
AND ( NVL (GJL.entered_dr, 0) != 0 OR NVL (GJL.entered_cr, 0) != 0)
AND GJL.code_combination_id = PO.code_combination_id
AND GJL.code_combination_id = GCC.code_combination_id
AND GJH.je_header_id = GJL.je_header_id
AND GJH.status = 'P'
AND GCC.enabled_flag = 'Y'
AND GJH.je_source = 'Purchasing'
AND GJH.je_category = 'Purchases'
AND GJH.encumbrance_type_id IN (1001, 1002)
AND GJH.actual_flag = 'E';
and Connor said...
I prefer LEADING to ORDERED, but with *any* hint, my thought process is normally:
a) put the hint in, either directly or via baseline/profile/etc to solve the problem in the short term
b) investigate why the optimizer did not derive the correct plan in the first place.
If (b) can be solved, then take the necessary action and remove the hint.
If (b) cannot be solved, then leave the hint in
Rating
(2 ratings)
Is this answer out of date? If it is, please let us know via a Comment