The query below performs fairly quickly, however when hit by several visitors at once causes the SQL Server CPU to spike greatly. How would you rewrite this query to reduce the impact?
SELECT *
FROM (SELECT TOP 1 a.adID, a.type, a.position, a.image, a.altText, a.caption, a.link, isNull(v.viewCount, 0) AS viewCount
FROM bannerAds a LEFT OUTER JOIN
(SELECT adID, count(viewID) AS viewCount
FROM bannerAdsViews
WHERE viewDateTime IS NOT NULL AND DateDiff(day, viewDateTime, GetDate()) = 0
GROUP BY adID) v ON a.adID = v.adID
WHERE a.startDate <= getDate() AND a.endDate >= getDate() AND a.position = 1 AND type = 'standard'
ORDER BY viewCount) pos1
UNION ALL
SELECT *
FROM (SELECT TOP 1 a.adID, a.type, a.position, a.image, a.altText, a.caption, a.link, isNull(v.viewCount, 0) AS viewCount
FROM bannerAds a LEFT OUTER JOIN
(SELECT adID, count(viewID) AS viewCount
FROM bannerAdsViews
WHERE viewDateTime IS NOT NULL AND DateDiff(day, viewDateTime, GetDate()) = 0
GROUP BY adID) v ON a.adID = v.adID
WHERE a.startDate <= getDate() AND a.endDate >= getDate() AND a.position = 2 AND type = 'standard'
ORDER BY viewCount) pos2