SELECT MAX (tran_date)
FROM abc
WHERE p_id = p_p_id
AND flag = 'Y'
AND ( ( p_c_number IS NULL
AND c_number IS NULL
)
OR (c_number = p_c_number)
)
AND ( ( p_m_number IS NULL
AND m_number IS NULL
)
OR (m_number = p_m_number)
)
AND ( ( p_s_number IS NULL
AND s_number IS NULL
)
OR (s_number = p_s_number)
);
I am using oracle as RDBMS ,i want to optimize this query
- Plan
SELECT STATEMENT ALL_ROWSCost: 357 Bytes: 39 Cardinality: 1
2 SORT AGGREGATE Bytes: 39 Cardinality: 1
1 TABLE ACCESS FULL TABLE abc Cost: 357 Bytes: 312 Cardinality: 8
EXPLAIN
or similar command to see the estimated execution plan of the query? Creating an index around most of these columns would probably help, and the query plan will help you see which ones. – cdhowieEXPLAIN
like it is in mysql ;-) But indeed, each optimization needs to be started with plan examination – zerkms