문제

Moving some complicated reporting sprocs to a centralized server and time went from 5 seconds to 30+ seconds.

validating what take so long via:

print '04 NWA Raw data Numeric'
print datediff(ss, @now, getdate())
set @now = GETDATE()

I am attempting to only pull local what this report needs with these queries:

1355 rows in 10 seconds----

select * 
into #nwaDump
from [Phoenix].[NWA].dbo.QISDataNumeric
where rowguid in (
select rowguid from [Phoenix].[NWA].[dbo].[QISDataText] nd
where nd.DataValue in ( '41310291            ' ) 
)  

249 rows in 28 seconds

select * 
into #nwaText 
from [Phoenix].[NWA].[dbo].[QISDataText] td
where td.DataValue in ( '41310291            ' ) 

Same two queries run on other server < 1 second return time.

Any ideas?

도움이 되었습니까?

해결책

You can try to use OPENQUERY for this, since it should make the filters on the linked server and then pull them to your other server:

SELECT *
INTO #nwaText 
FROM OPENQUERY(Phoenix,'SELECT * FROM [NWA].[dbo].[QISDataText] 
                        WHERE DataValue in ( ''41310291            '' )')
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top