I need help with my query. This table has 144 million rows and this is a stage table ( where we insert data from another table). I didn't have indexes before and the job had been running for more than 9 hours. I added the non clustered index to this table with multiple columns ( AdvertiserName,MediaPlanName,MediaPlanNumber, CreativeDescription) because this combination makes it unique. But even now execution plan shows Table Scan and not non-clustered index scan and no improvement with performance.
This is the query below, and it is taking very long time to summarize data into csv file using SSIS. How can I improve performance on this query? Please help!! It is taking very long time to run. :(
SELECT
AdvertiserName,
AdvertiserID,
MediaPlanNumber,
MediaPlanName,
PublishingSiteName,
SiteName,
Week_Begin_Monday,
CreativeDescription,
SUM(CAST(ViewCount AS BIGINT)) ViewCount,
SUM(CAST(ClickCount AS BIGINT)) ClickCount,
Media,
Segment_Name,
Segment_CD,
Group_Name,
Group_CD,
Channel,
LOB,
Creative_Message,
Creative_Category,
Creative_Type,
SUM(GRP) GRP,
Intended_Delivery_Screen
FROM Stage_MM240(NOLOCK)
GROUP BY AdvertiserName,
AdvertiserID,
MediaPlanNumber,
MediaPlanName,
PublishingSiteName,
SiteName,
Week_Begin_Monday,
CreativeDescription,
Media,
Segment_Name,
Segment_CD,
Group_Name,
Group_CD,
Channel,
LOB,
Creative_Message,
Creative_Category,
Creative_Type,
Intended_Delivery_Screen