Revised vefn_getChronology to speed up performance
This commit is contained in:
@@ -215,6 +215,12 @@ DeletedAuditID int
|
||||
WITH EXECUTE AS OWNER
|
||||
AS
|
||||
BEGIN
|
||||
--added rhm/jcb 20121218i
|
||||
declare @tmpTable table
|
||||
(
|
||||
icontentid int primary key
|
||||
)
|
||||
insert into @tmpTable select icontentid from vefn_tblchilditems(@ProcItemID,@ProcItemID,1)
|
||||
--added jcb 20111122
|
||||
declare @dts datetime
|
||||
set @dts = (select dts from items where itemid = @ProcItemID )
|
||||
@@ -242,6 +248,7 @@ set @dts = (select dts from items where itemid = @ProcItemID )
|
||||
where Number is not null
|
||||
--added jcb 20111028_1827
|
||||
and ca.contentid != (select contentid from items where itemid = @procitemid)
|
||||
and ca.contentid in (select icontentid from @tmpTable)
|
||||
--end added jcb 20111028_1827
|
||||
--added jcb 20111122
|
||||
--and ca.ContentID in (SELECT [ContentID] FROM ContentAudits where dts > (select dts from items where itemid = @ProcItemID ))
|
||||
@@ -303,11 +310,12 @@ and ca.dts > @dts
|
||||
-- inner join tblitems ti on ca.contentid = ti.contentid
|
||||
WHERE ca.DeleteStatus = 0 AND
|
||||
--added jcb 20111028_1827
|
||||
ca.contentid != (select contentid from items where itemid = @procitemid) and
|
||||
ca.contentid != (select contentid from items where itemid = @procitemid)
|
||||
and ca.contentid in (select icontentid from @tmpTable)
|
||||
--end added jcb 20111028_1827
|
||||
--added jcb 20111122
|
||||
--ca.dts > (select dts from items where itemid = @ProcItemID )
|
||||
(ca.dts > @dts or ca.actiondts > @dts)
|
||||
and (ca.dts > @dts or ca.actiondts > @dts)
|
||||
--end added jcb 20111122
|
||||
UNION
|
||||
SELECT distinct
|
||||
@@ -330,13 +338,14 @@ ca.contentid != (select contentid from items where itemid = @procitemid) and
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and number is not null and deletestatus > 0 and ca.dts = dts) DeletedAuditID
|
||||
FROM ContentAudits ca
|
||||
-- inner join tblitems ti on ca.contentid = ti.contentid
|
||||
WHERE ca.DeleteStatus > 0 AND
|
||||
WHERE ca.DeleteStatus > 0
|
||||
--added jcb 20111028_1827
|
||||
--ca.contentid != (select contentid from items where itemid = @procitemid) and
|
||||
--end added jcb 20111028_1827
|
||||
--added jcb 20111122
|
||||
--ca.dts > (select dts from items where itemid = @ProcItemID )
|
||||
(ca.dts > @dts or ca.actiondts > @dts)
|
||||
and ca.contentid in (select icontentid from @tmpTable)
|
||||
and (ca.dts > @dts or ca.actiondts > @dts)
|
||||
--end added jcb 20111122
|
||||
order by ca.DTS,ActionDTS
|
||||
|
||||
@@ -362,6 +371,7 @@ order by ca.DTS,ActionDTS
|
||||
inner join @Report rpt on ca.contentid = rpt.contentid and ca.auditid = rpt.lastauditid
|
||||
where ca.auditid not in (select auditid from @report)
|
||||
and rpt.lastauditid is not null
|
||||
and ca.contentid in (select icontentid from @tmpTable)
|
||||
return
|
||||
end
|
||||
GO
|
||||
|
Reference in New Issue
Block a user