0

I am going to use hint OPTION (RECOMPILE) or OPTION (OPTIMIZE FOR UNKNOWN) at the end of query in my sp.Query contains union all operator so shall i use cte?will it improve or affect the performance?.suggest please.

Example

;with cte
{
QUERY 1
UNION ALL
QUERY 2
}

select * from cte OPTION (RECOMPILE);
Ram
  • 727
  • 2
  • 16
  • 33
  • You have to compare query plans and measure execution time on your data - it is impossible to give any generic hints here. What about CTE - I can't see any reason to use CTE here, you can simply use union query. – Arvo Dec 11 '18 at 08:27
  • Cte is used here for using the hint OPTION (RECOMPILE) at the end of query.so cte is used here. – Ram Dec 11 '18 at 08:38

0 Answers0