🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: bit.listserv.sqlinfo
Article #241

Tempdb Re-Org ?

#241
From: Lou
Date: Sun, 10 Sep 2000 16:32
84 lines
4503 bytes
Hi,

I have a very large query that includes multiple nested selects.

It works fine on my development machine, but in production (with large
volume) it fails because the Tempdb gets too large.  I added more space to
tempdb (now it has about 300mb).  The first time the query is invoked, it
works (tempdb used about 250mb).

However, the next time this query is executed, it seems that tempdb keeps
increasing.  The docs say that Tempb is initialized to the default
allocations (in my case 300mb) whenever sql server is started.

Is there a way of re-organizing tempdb back to its original state without
shutting down sql server ?

fyi here is my query:

CREATE PROCEDURE [m_spPrintInvoice] @ClientID integer, @EndDate datetime AS
if @ClientID < 1
Begin
SELECT M_Clients_Dta.ClientType, M_Clients_Dta.TaxId,
M_Clients_Dta.AccountStatus,
M_Clients_Dta.TaxExemptStatus, M_Clients_Dta.BillingPlanCode,
M_Clients_Dta.AccountName,
m_controldata_cod.description AS PlanDescription, M_Addresses_Dta.Street +
char(13) +M_Addresses_Dta.City + '   '+M_Addresses_Dta.State+ ' ' +
M_Addresses_Dta.Zip as ClientAddress, M_Clients_Dta.ClientID,
M_Addresses_Dta.EntityID, m_invoices_dta.invoiceid,
m_invoices_dta.PeriodStartDate,  m_invoices_dta.AdditionalText,
m_invoices_dta.PeriodEndDate, m_invoices_dta.OpeningBalance,
m_invoices_dta.TotalAmount,
PastDueText =
case
when m_invoices_dta.openingbalance < .01 then ''
else (SELECT Description from m_controldata_cod where controlgroup = 'IT'
and controltype = 'PD')
end
FROM M_Clients_Dta
Full Outer Join M_BillingPlans_Cod ON M_Clients_Dta.BillingPlanCode =
M_BillingPlans_Cod.BillingPlanCode
Full Outer JOIN M_Addresses_Dta ON M_Addresses_Dta.AddressType = 'BL' AND
M_Clients_Dta.ClientID = M_Addresses_Dta.EntityID
Join m_controldata_cod ON
m_clients_dta.billingplancode = m_controldata_cod.controltype and
controlgroup = 'BL'
Join m_invoices_dta ON m_invoices_dta.PeriodEndDate = @EndDate and
m_invoices_dta.clientid = m_clients_dta.clientid
end
else
Begin
SELECT M_Clients_Dta.ClientType, M_Clients_Dta.TaxId,
M_Clients_Dta.AccountStatus,
M_Clients_Dta.TaxExemptStatus, M_Clients_Dta.BillingPlanCode,
M_Clients_Dta.AccountName,
m_controldata_cod.description AS PlanDescription, M_Addresses_Dta.Street +
char(13) +M_Addresses_Dta.City + '   '+M_Addresses_Dta.State+ ' ' +
M_Addresses_Dta.Zip as ClientAddress, M_Clients_Dta.ClientID,
M_Addresses_Dta.EntityID, m_invoices_dta.invoiceid,
m_invoices_dta.PeriodStartDate,   m_invoices_dta.AdditionalText,
m_invoices_dta.PeriodEndDate, m_invoices_dta.OpeningBalance,
m_invoices_dta.TotalAmount,
PastDueText =
case
when m_invoices_dta.openingbalance < .01 then ''
else (SELECT Description from m_controldata_cod where controlgroup = 'IT'
and controltype = 'PD')
end
FROM M_Clients_Dta
Full Outer Join M_BillingPlans_Cod ON M_Clients_Dta.BillingPlanCode =
M_BillingPlans_Cod.BillingPlanCode
Full Outer JOIN M_Addresses_Dta ON M_Addresses_Dta.AddressType = 'BL' AND
M_Clients_Dta.ClientID = M_Addresses_Dta.EntityID
Join m_controldata_cod ON
m_clients_dta.billingplancode = m_controldata_cod.controltype and
controlgroup = 'BL'
Join m_invoices_dta ON m_invoices_dta.PeriodEndDate = @EndDate and
m_invoices_dta.clientid = m_clients_dta.clientid
Where m_clients_dta.clientid = @clientid
end


Thanx ... Lou
santlou@worldnet.att.net
Technical Details
Message-ID: <ZIOu5.1972$6f1.177556@bgtnsc05-news.ops.worldnet.att.net>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-east!sn-xit-uk!supernews.com!194.42.224.136.MISMATCH!diablo.netcom.net.uk!netcom.net.uk!diablo.theplanet.net!europa.netcrusader.net!152.163.239.129!portc01.blue.aol.com!wn4feed!worldnet.att.net!135.173.83.19!wnmasters2!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11355a,51c13aa0aea91e70,start
X-Google-Attributes: gid11355a,public
X-Google-ArrivalTime: 2000-09-10 09:33:02 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-east!sn-xit-uk!supernews.com!194.42.224.136.MISMATCH!diablo.netcom.net.uk!netcom.net.uk!diablo.theplanet.net!europa.netcrusader.net!152.163.239.129!portc01.blue.aol.com!wn4feed!worldnet.att.net!135.173.83.19!wnmasters2!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail
From: "Lou" <Lou@aol.com>
Newsgroups: bit.listserv.sqlinfo
Subject: Tempdb Re-Org ?
Lines: 86
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2615.200
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Message-ID: <ZIOu5.1972$6f1.177556@bgtnsc05-news.ops.worldnet.att.net>
Date: Sun, 10 Sep 2000 16:32:57 GMT
NNTP-Posting-Host: 12.79.160.202
X-Complaints-To: abuse@worldnet.att.net
X-Trace: bgtnsc05-news.ops.worldnet.att.net 968603577 12.79.160.202 (Sun, 10 Sep 2000 16:32:57 GMT)
NNTP-Posting-Date: Sun, 10 Sep 2000 16:32:57 GMT
Organization: AT&T Worldnet