Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Execution of this query is slow

Author  Topic 

Mapper
Starting Member

12 Posts

Posted - 2008-09-23 : 10:54:50
The execution of this query is somewhat slow. I am curious if my Syntax needs something changed:

SELECT
CAST(ROW_NUMBER() OVER (ORDER BY c.[PCCITZID]) AS INT) AS OBJECTID,
Cast(o.[PMPARCEL] AS nvarchar(14)) AS PIN,
o.[PCCITZID] AS CITIZENID,
o.[POPRIMOWNR] AS PRIMARYCONTACT,
o.[PMYEAR],
c.[PCNAME],
c.[PCFIRSTNAM] + ' ' + c.[PCLASTNAME] AS CombinedName,
c.[PCMSTREET] AS HOUSENUMBER,
c.[PCMPREDIR] AS PREDIR,
c.[PCMSTRTNAM] AS STREETNAME,
c.[PCMSTRTSFX] AS STREETSUFFIX,
c.[PCMPSTDIR] AS POSTDIR,
c.[PCMSECUNIT] AS SECUNIT,
c.[PCMSECOND] AS UNITNUMBER,
c.[PCMCITY] AS CITY,
c.[PCMSTATE] AS STATE,
LEFT(c.[PCMZIPCODE], 5) AS Zip

FROM caidata.caisoa.dbo.ptownr AS o
INNER JOIN caidata.caisoa.dbo.ptcitz AS c ON o.[pccitzid] = c.[pccitzid]

WHERE ((LEFT(o.[PMPARCEL], 2) = 'RP') OR (LEFT(o.[PMPARCEL], 2) = 'SC')) AND
o.[PMYEAR] =
(SELECT MAX([PMYEAR]) FROM caidata.caisoa.dbo.ptmst WHERE [PMPARCEL] = o.[PMPARCEL])

http://www.BackcountrySecrets.com - Find and share places to play outdoors

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-09-23 : 11:03:36
What does Execution plan say?
Go to Top of Page

Mapper
Starting Member

12 Posts

Posted - 2008-09-23 : 13:24:22
Remote Query 42%
Filter 0%
Remote Query 1%
Merge Join 0%
Sort 1%
Remote Query 42%
Merge Join (Inner Join) 10%
Segment 3%
Sequence Project (Compute Scalar) 0%
Compute Scalar 2%
SELECT 0%


http://www.BackcountrySecrets.com - Find and share places to play outdoors
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-09-23 : 13:29:01
Its because you are pulling data from Linked Server.
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-09-23 : 17:02:05
dear sodeep, how can we get the above stated values and based on those, how are you saying that is from linked server?

please provide me valuble information

Arnav
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-09-23 : 17:05:43
With [Remote Query] and Four-part Naming Convention.
Go to Top of Page
   

- Advertisement -