Adding a single row union dramatically reduces performance on a CTE query

,

I’m no expert, but I think I have seen this before myself and it is pretty bewildering.

I will say, I have learned of a trick that may help - specifically the OPTION(RECOMPILE) thing in a BAQ:

But heed the statistics advice, too.