Revised vefn_getChronology to speed up performance
This commit is contained in:
@@ -2699,6 +2699,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 )
|
||||
@@ -2726,6 +2732,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 ))
|
||||
@@ -2787,11 +2794,42 @@ 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
|
||||
5 src,
|
||||
-- cast(ident_current('contentaudits') + 1 as bigint) auditid
|
||||
-- (select max(auditid) + 1 from contentaudits) [AuditID]
|
||||
ca.[AuditID]
|
||||
,ca.[ContentID]
|
||||
,[Number]
|
||||
,[Text]
|
||||
,[Type]
|
||||
,[FormatID]
|
||||
,[Config]
|
||||
,ca.[DTS] cadts
|
||||
,ca.[UserID]
|
||||
,ca.[DeleteStatus]
|
||||
,ActionDTS
|
||||
,(select min(dts) from itemaudits where contentid = ca.contentid) ItemDTS
|
||||
,(select max(auditid) from contentaudits where ca.contentid = contentid and number is not null) LastAuditID
|
||||
,(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
|
||||
--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 )
|
||||
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
|
||||
|
||||
@@ -2817,6 +2855,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