对每个节点要执行跟下面的sql语句类似的统计共三次declare @i integer; 
declare @timeST integer, @nMaxValue float, @timeMaxValue bigint, @nMinValue float, @timeMinValue bigint, @nSumValue float, @timeCK integer, @timeUp integer, @timeDown integer;
declare @id integer, @date bigint;
 begin
 select @id = :ID, @date = :Date;
 select * into #tmp from DY_StValueEnd where iMeasurPointegerID = @id and iDate between :DateSt and :DateEd;
 select @timeST=sum(iStTime), @nMaxValue=max(fMaxValue), @nMinValue=min(fMinValue), @nSumValue=sum(fAvgValue*iStTime), @timeCK=sum(iTCheckOut), @timeUp=sum(iOffUpTime), @timeDown=sum(iOffDownTime) from #tmp;
 select @timeMaxValue=fMaxValueTime from #tmp where fMaxValue = @nMaxValue;
 select @timeMinValue=fMinValueTime from #tmp where fMinValue = @nMinValue;
 select @i=count(*) from DY_MeasureDataMonth where iMeasurPointegerID = @id and iDate = @date;
 if @i>0 update DY_MeasureDataMonth set iStTime=@timeST, fMaxValue=@nMaxValue, fMaxValueTime=@timeMaxValue, fMinValue=@nMinValue, fMinValueTime=@timeMinValue, fAvgValue=@nSumValue/@timeST, fCheckOut=@timeCK/cast(@timeST as float), fOffUpRatio=@timeUp/cast(@timeST as float), fOffDownRatio=@timeDown/cast(@timeST as float), iTCheckOut=@timeCK, iOffUpTime=@timeUp, iOffDownTime=@timeDown where iMeasurPointegerID = @id and iDate = @date
 else insert into DY_MeasureDataMonth values(@id, @date, @timeST, @nMaxValue, @timeMaxValue, @nMinValue, @timeMinValue, @nSumValue/@timeST, @timeCK/cast(@timeST as float), @timeUp/cast(@timeST as float), @timeDown/cast(@timeST as float), @timeCK, @timeUp, @timeDown);
 drop table #tmp;
 end为了保持数据一致 我是做了事务的 只有全部统计完成才提交但是做到6000多的节点的时候 它就说没空间再建立#tmp了 第一次做真实应用 不知道怎么处理是我不该这么处理临时表么 因为每次建立的临时表字段结构是完全相同的
还是说这么多节点的统计不应该做成一个事务
或者我写sql 以及 建立表的索引时 的效率问题 统计这6000多个点已经花了近16分钟