Variable vs hardcoded value in SQL query
763899May 12 2010 — edited May 13 2010Hi Gurus,
I have a SQL query inside a function that looks similar (i'm showing the "where" clause here only) to the below:
WHERE ID = variable_id (by the way this two have exactly the same type, number(20))
and
WHERE ID = 100
In the first option that uses variable it takes 4 secs to complete the query, while the second one that uses hardcoded value completes in milliseonds. Im new to oracle but been to other dbms and havent seen such behaviour. Anyone encountered or know what maybe the cause? I thought of not pasting here the explain plan since its just a question of variable vs hardcoded value.
rgds.