Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql SSIS执行导致TempDB增长_Sql_Sql Server_Visual Studio_Ssis - Fatal编程技术网

Sql SSIS执行导致TempDB增长

Sql SSIS执行导致TempDB增长,sql,sql-server,visual-studio,ssis,Sql,Sql Server,Visual Studio,Ssis,我有一个包,它包含一个Foreach循环,在它里面我有一个任务运行程序执行,它执行一个查询,而不使用orderby或索引 我在里面的代码是: declare @Sdate int set @Sdate=? declare @Edate int set @Edate=? ---------------ActiveShowingType------- update att.FactWorkPeriod set ActiveShowingType=0 update w set w.Act

我有一个包,它包含一个Foreach循环,在它里面我有一个任务运行程序执行,它执行一个查询,而不使用orderby或索引 我在里面的代码是:

  declare @Sdate int 
set @Sdate=?
declare @Edate int 
set @Edate=?

---------------ActiveShowingType-------
update att.FactWorkPeriod
set ActiveShowingType=0 
update w 
set w.ActiveShowingType=case when w.ShowingTypeId=c.ShowingTypeID then 1
else 0 end
from att.FactWorkPeriod w 
inner join att.DimCode c on w.CodeId=c.[CodeId]
where w.DateSK between @Sdate and @Edate
 ----------------------  HasContract-------------------
  declare @YearStart char(4)=(select min (YearIR) from att.FactWorkPeriod w 
 inner join gnr.DimDate d on w.DateSK=d.DateSK)
 update w1 
set w1.HasContract =case when t.PersonSK is not null then 1 else 0 end 
from att.FactWorkPeriod w1
inner join (
select distinct
(select max(datesk) from gnr.dimdate dd where dd.yearmonthIR=d.YearMonthIR)as dateSK,
p.PersonSK
from gnr.DimDate d 
left join  att.DimPerson p on d.FullDateIR between p.EmployDate and p.ExitDate
 where  YearIR between @YearStart and (select YearIR from gnr.DimDate where IsToday=1)  and d.LastDayOfMonth=1
 )t on t.dateSK=w1.DateSK and t.PersonSK=w1.PersonSK
 where w1.DateSK between @Sdate and @Edate
 --------------------ContractTypeId------------------
 if (case when (select Count(isnull(GroupId ,0)) from kasrawarehouse.att.DimGroup)<1 then 0 else 1 end= 1 )
 begin 
 update w2
 set w2.ContractTypeId=t.ContractTypeId
  from att.FactWorkPeriod w2
 inner join ( select w3.DateSK , w3.PersonSK , case when gp.groupid is not null then 0
else 1 end as ContractTypeId from att.FactWorkPeriod w3
 inner join att.DimPerson p on w3.PersonSK=p.PersonSK
inner join gnr.DimDate d on d.DateSK=w3.DateSK
left join KasraForWarehouseConvert.gnr.GroupPerson gp 
 ON d.FullDateIR BETWEEN gp.SDate COLLATE Arabic_CI_AS AND gp.EDate COLLATE Arabic_CI_AS
 and gp.PersonelID=p.PersonBK
 and gp.GroupID in (select distinct GroupId from [Att].[DimGroup])--='15027' 
where d.LastDayOfMonth=1  )t on t.DateSK=w2.DateSK and t.PersonSK=w2.PersonSK
 where w2.DateSK between @Sdate and @Edate
 end 
  ---------------  به روز رسانی واحد سازمانی که از بین رفته ------
 update w4
set w4.OrgSK='999999999'
 from att.FactWorkPeriod w4
inner join (select distinct OrgSK from att.FactWorkPeriod w5
where w5.OrgSK not in (select distinct OrgIdPreffix from att.DimOrg)) t on t.OrgSK=w4.OrgSK
 where w4.DateSK between @Sdate and @Edate
 -------- پاک کردن افرادی که پاک شده اند -------
delete  from att.FactWorkPeriod 
where PersonSK not in (select distinct PersonSK from att.DimPerson)
and DateSK between @Sdate and @Edate
在执行过程中,tempDb增长很快,当驱动器已满时停止。如何执行它而不将其存储在tempDb上,而只插入和更新数据?
PS-我在Sql Server内部运行代码,它可以正常工作。

TempDB是一个优化的存储位置,Sql引擎可以根据需要选择使用它来处理查询/操作。出现这种情况时,需要使用它,并且TempDB文件的增长是正常的。您可以在Microsoft文档中阅读更多有关TempDB中具体存储的内容以及SQL引擎如何使用它的信息

在TempDB中的对象不再存在后,TempDB后面的文件所消耗的存储可能会持续存在,因为SQL引擎不会以本机方式将所消耗的空间释放回磁盘,但会被未来的操作重新使用—实际上,使用TempDB的磁盘上的相同字节将被覆盖

因此,您不应该太担心您看到的增长,因为这是必要的,并且在未来的操作中可以重复使用。当应用相同的工作负载时,您的TempDB不会呈指数级增长


限制其使用的唯一方法是将TsmpDB中的文件预增长到您希望的大小,并减少这些文件所在磁盘上分配的可用空间,这样就没有什么可增长的了。但这将是一种非常糟糕的做法,可能会导致查询和进程出现许多性能问题。

如果您的存储设备用于填充数据,您的存储设备有多小,或者您在一次事务中要处理多少数据?您不能停止SQL Server使用tempdb,如果它认为需要使用它,那么它将使用它来创建工作表之类的东西。