Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


sql query fills up tempdb with greater than 300 gb


sql query fills up tempdb with greater than 300 gb

Author
Message
RahulSingh
RahulSingh
SSC Rookie
SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)

Group: General Forum Members
Points: 44 Visits: 200
Hi,

Below mentioned query, whenever it runs it fills up tempdb space and resulting disk space issues and it's taking more than 10 hours to complete. I have checked the indexes and statistics of the related tables of that query they are not fragmented. Please help me resolving the issue-

Query-

SELECT distinct '0' AS sno, a.iOdfno AS id, a.iAcNo, a.iShipToParty, a.cPType, REPLACE(a.cPType, '62', 'OTS') AS Ptype,
a.cSiteCode, a.iId, a.cPName, a.iId AS scopeid, a.iFranchiseeAcNo,a.icno as ContactNo,
isnull(d.vcAddr_Street,'')+isnull(d.vcaddr_street1,'')+isnull(d.vcaddr_loc,'') as Address ,a.dtExpDate, a.cSONo,
b.vcAcName, c.vcAcName AS FName, d .vcAddr_City, e.vcCityName, ISNULL(a.cUsedFor, '') AS UsedFor, a.iJSNo,
ISNULL(a.vcRodlcNo, '') AS vcRodlcNo, ISNULL(a.dtActDate, '') AS ActDate, IsNull(a.crono, '') AS LinEid,

CASE WHEN a.vcRodlcNo IS NULL THEN 'RODLC NO. not filled'
WHEN a.iFranchiseeAcNo IS NULL THEN 'Franchisee assignment not done'
WHEN a.dtActDate = '1/1/1900' OR a.dtActDate IS NULL THEN 'ACD not filled'
WHEN a.dtActDate IS NOT NULL AND a.dtActDate <> '1/1/1900' THEN 'Complete'
END AS status,
z.cname AS Hub, a.csapcode,case when o.vcfilename is null then 'No' else
'<a href=OpenFileViewer1(''IC'',''' + rtrim(a.iodfno) + ''',''H'','
+ convert( varchar(30), a.iid) + ')> View File </a>' end as vcfile,a.dtjsheet_trigger,isnull(O.dtICUplaod,'') as dtICUplaod ,isnull(a.dtacdentereddate,'') as dtacdentereddate
,isnull(inv.invoiceno,'') as [InvoiceNo],case when o.vcfilename is null then 'No' else 'Yes' end as IcUploadStatus ---,inv1.Invoice_amt,inv1.Invoice_date
FROM
(
select * FROM R_Scope WHERE (iOdfno <> '0-0') and (cPType = '62') AND (cSONo IS NOT NULL)
) a
left outer join rl_jsheet_ots o on a.iid=o.iscopeid
INNER JOIN SFA.dbo.Account b ON a.iAcNo = b.iAcNo
inner join sFA.dbo.codes z ON b.chub = z.ccode
left outer JOIN SFA.dbo.Account c ON c.iAcNo = a.iFranchiseeAcNo
INNER JOIN dbo.R_sitemaster d ON a.cSiteCode = d .vcSite_Code
LEFT OUTER JOIN SFA.dbo.State_City e ON d .vcAddr_City = e.iId
inner join
rec_revenue_sap_new inv on ltrim(rtrim(a.icno))=convert(varchar,inv.icno) and ltrim(rtrim(a.crono))=convert(varchar,inv. crono)-- left outer join


Thanks & Regards
Rahul Singh
Tarun Jaggi
Tarun Jaggi
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1323 Visits: 698
Share the execution plan of the query.
Also check whether the table(s) has required index(s).
sqlbuddy123
sqlbuddy123
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1212 Visits: 2243
Post the execution plan ..

--
SQLBuddy
benjamin.reyes
benjamin.reyes
Old Hand
Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)Old Hand (305 reputation)

Group: General Forum Members
Points: 305 Visits: 2283
http://technet.microsoft.com/en-us/library/ms190646.aspx


To save an execution plan by using SQL Server Management Studio options

Generate either an estimated execution plan or an actual execution plan by using Management Studio.

In the Execution plan tab of the results pane, right-click the graphical execution plan, and choose Save Execution Plan As.

As an alternative, you can also choose Save Execution Plan As on the File menu.

In the Save As dialog box, make sure that the Save as type is set to Execution Plan Files (*.sqlplan).

In the File name box provide a name, in the format <name>.sqlplan, and then click Save.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search