Ho sperimentato situazioni in cui UNION ha eseguito una query molto più lenta di UNION ALL con un DISTINCT dopo. Quindi, anche se non ho una spiegazione per il piano di query errato (statistiche e indici vanno bene?), ti suggerisco di provare quanto segue:
select distinct * from (
select *
from #finalResults
where intervalEnd is not null
union all
select
two.startTime,
two.endTime,
two.intervalEnd,
one.barcodeID,
one.id,
one.pairId,
one.bookingTypeID,
one.cardID,
one.factor,
two.openIntervals,
two.factorSumConcurrentJobs
from #finalResults as one
inner join #finalResults as two
on two.cardID = one.cardID
and two.startTime > one.startTime
and two.startTime < one.intervalEnd
)