存储过程在ColdFusion 9中运行缓慢

时间:2014-07-01 18:01:55

标签: sql-server stored-procedures coldfusion coldfusion-9

我有一个存储过程从昨天开始运行起来非常慢,我无法找到原因。我在SQL Management Studio中直接运行SP,返回结果需要+/- 6秒,但是当我从脚本运行相同的东西时,需要40多秒才能返回相同的内容。没有任何代码/查询被更改。 我尝试重启服务器和CF应用程序服务器但没有成功。有没有关于如何调试此事的任何想法?

我创建了一个小脚本只是为了单独运行SP,这里是代码。

 <cfquery name="results" datasource="#ds#">
            DECLARE @owners Table (ownerid varchar(50) NULL,category varchar(50) NULL);
            insert into @owners (ownerid, category)
            exec survey.dbo.sp_FilteredOwners
                '2014-06-30 00:00:00.0',
                '2014-07-01 23:59:59.9',
                '35',
                '2008013110482896439177,2010080209524690985587',
                'F4EF72AF-C0C9-FF31-14CE48E082472995,19C963DD-9C1D-91B5-6B7A707C95EEFDDA',
                'ABREGOJE,ACCAJ,AFSHARPOURA,AGUAYOC',
                'AACHENWINANSJ,ABREGOJE,ACCAJ,ADAMSB',
                '',
                '',
                '',
                '',
                '',
                '',
                '',
                'Eyebrow,Follicular Unit Extraction,Graft Removal/Reimplantation,Hair Transplantation,Scar Revision,Test Survey,Unassigned'

           DECLARE @o2 Table (ownerid varchar(50) NULL,category varchar(50) NULL, tag varchar(50) NULL);
              insert into @o2 (ownerid, category, tag)
              select ownerid, category, max(questiontag)
              from @owners o
              join survey.dbo.results r on o.ownerid = r.owneridfk
              left join survey.dbo.questionsadmin qa on r.answeridfk = qa.answeridfk and qa.tagidfk in (102,105,117,123,132)
              left join survey.dbo.questiontags qt on qa.tagidfk = qt.id
              group by ownerid, category

            select distinct
            o.category as category, o.category as status,
            o.tag,
            s.name, st.surveyeventid,
            c.contactid as contactid, c.first, c.last,
            sr.completed as datecomplete, st.ownerIdfk, st.finalScore, st.surveyid,
            cc.clientcontactid, cc.leadsource,
            se.eventdate, se.ProcedureName, clm.LocationName, se.salesperson, se.SpecialistName, stm.surveytitle,
            sst.statusname, st.serviceRepID, rep.sr_name
            from @o2 o
            join survey.dbo.survey_results sr on o.ownerid = sr.ownerid
            join survey.dbo.surveys s on sr.surveyidfk = s.id
            join sigweb.dbo.survey_tracking st on o.ownerid = st.owneridfk
            join survey.dbo.survey_events se on st.surveyeventid = se.id
            join survey.dbo.client_contacts cc on sr.contactid = cc.contactidfk
            join sigweb.dbo.contact c on sr.contactid = c.contactid
            join sigweb.dbo.survey_types_main stm on sr.surveyidfk =  stm.surveyidfk
            join sigweb.dbo.survey_statusTypes sst on st.surveyStatusID = sst.statusID
            join survey.dbo.clientlocationmap clm on se.doctorid = clm.doctorid and clm.clientbrandid = '35'
            left join sigweb.dbo.servicereps rep on st.servicerepid = rep.servrepid
            order by sr.completed desc

        </cfquery>

        <cfdump var='#results#'>

0 个答案:

没有答案