I am inserting 5308194 records into this #Temp
table, and it is taking about 8 seconds and was thinking that it shouldn't take that much time
Is there a better way to do this, or maybe BULK Insert, creating the temp table before the insert?
SELECT g.CustomerId, g.LogDate
INTO #Temp
FROM vwGuidelineLog g --nolock
WHERE g.LogDate >= '2017-10-01'
AND g.LogDate < DATEADD(DAY, 1, '2018-09-30')
DDL
CREATE VIEW [dbo].[vwGuidelineLog]
WITH SCHEMABINDING
AS
SELECT
GuidelineLogID, LogDate, FileName, CustomerID, GuidelineLinkId, CountryId
FROM
dbo.GuidelineLog
WHERE
(GuidelineLinkId IS NOT NULL)
Clustered index
CREATE UNIQUE CLUSTERED INDEX [IdX_vwGuidelineLog]
ON [dbo].[vwGuidelineLog] ([GuidelineLogID] ASC)
Index for LogDate
:
CREATE NONCLUSTERED INDEX [IDX_GuidelineLogDate]
ON [dbo].[vwGuidelineLog] ([LogDate] ASC)