SQL Server: 2014
Problem: I am running a query that joins 3 views and produces results. Query takes over 8 minutes to run, but it runs without an error and produces correct output.
Can you please take a look at my query and tell me why it takes 8 mins for it to run? Server has no shortage of resources, all the other tasks are running without a problem.
Thank you.
select DISTINCT
n1.[Bill Account Number],
n1.[Service Account Number],
n1.[Service Customer Name],
n1.[Service Street Name],--Service address
n1.[Service Street Number],
n1.[Apartment Number],
n1.[Telephone Number],
n1.[Company Name],
n1.[Core Service Type],
n1.[Service Status],
n1.[Service Type],
n2.[USEC Code],
n2.[Rate Table],
n2.[USEC Desc],
n2.[Recurring Amount],
n2.[USEC Quantity],
n3.[Service Account Number],
n3.[Company Name] as COMPANY
FROM [dbo].[View1] AS n1
INNER JOIN
[dbo].[View2] AS n2
ON
n1.[Bill Account Number]=n2.[Bill Account Number]
INNER JOIN
[dbo].[View3] AS n3
ON
n2.[Service Account Number]=n3.[Service Account Number];