One of our customers is reportedly seeing an instance of the SQL below appearing to be run on their Laserfiche database at a average frequency of once every eight seconds.
(@P1 int,@P2 int)select toc.tocid as id,toc.toc_sdctl,case when toc.toc_flags & 32 = 32 then 1 else 0 end as hasacl,case when toc.parentid is null then 0 else toc.parentid end,case when toc.etype >= 0 then 1 else 0 end from toc join searchresult10 sr on toc.tocid = sr.tocid and (toc.toc_flags & 2048) = 0 and toc.tocid<>2 left outer join toc as linktoc with (nolock) on case when toc.etype = -1 then toc.linkto else toc.tocid end = linktoc.tocid where sr.rsid=@P1 and ((toc.etype=-2 or toc.etype>=0) or (toc.etype = -1 and (linktoc.etype=-2 or linktoc.etype>=0))) and ((toc.toc_flags & 1048576) = 0 or toc.tocid = 1 or not exists (select * from entry_tag et join tag t on et.tag_id = t.tag_id where t.is_secure = 1 and et.tocid <> 1 and et.tocid = toc.tocid and (toc.etype <> -1 or et.tocid = toc.linkto) and not exists (select * from sess_tag st where st.tag_id = et.tag_id and st.sess_id = @P2 ))) order by case when toc.etype>=0 or (toc.etype=-1 and exists (select * from toc l where l.tocid=toc.linkto and l.etype >= 0)) then 1 else 0 end,(select date_val from propval where propval.pos=0 and propval.tocid=linktoc.tocid and propval.prop_id=26) desc,toc.name desc
Our customer has indicated that the above SQL is resource intensive and in that regard is having performance implications on their Laserfiche system. Our customer would like to know what the SQL does, what could be initiating the SQL and what can be done to restrict the SQL from running so often and would also like to understand ways to make the SQL less resource intensive and therefore have less of a performance impact on the system.