I have a recursive query which executes very fast if the WHERE clause contains a constant but becomes very slow if I replace the constant with a parameter havin
WHERE
You should use a plan guide to freeze the plan you want.