AnsweredAssumed Answered

Timeout error

Question asked by jarmdq on Oct 5, 2015
Latest reply on Oct 6, 2015 by gregor

Hi,

 

I have a .NET WebService that retrieves data for a report and in production environment is throwing a timeout error.

I've configured a timeout of 60 seconds and i think that have to be enough to retrieve the information.

 

I'm Querying  38 tags, calling this query for each tag:

 

SELECT TOP 1 T3.TIME, T3.VALUE, T4.OFFSET, T3.ISDISCRETEVALUE

  FROM (SELECT TOP 1 T2.TIME, T2.VALUE,

        (CASE WHEN T1.POINTTYPEX = 'Digital' THEN 1 ELSE 0 END) ISDISCRETEVALUE,

        (CASE WHEN T1.POINTTYPEX = 'Digital' THEN CAST(T2.VALUE AS int32) ELSE 0 END) CODE

        FROM (SELECT  TAG, POINTTYPEX, DIGITALSET FROM PIPOINT..CLASSIC WHERE TAG = 'xxx') T1

        INNER JOIN (SELECT TAG, TIME, VALUE, STATUS FROM PIARCHIVE..PICOMP2 WHERE TAG = 'xxx' AND TIME <= '2015-10-05' ) T2 ON T2.TAG = T1.TAG

        ORDER BY T2.TIME DESC ) T3

        INNER JOIN (SELECT CODE, OFFSET, NAME FROM PIDS..PIDS) T4 ON T4.CODE = T3.CODE

ORDER BY T3.TIME DESC

 

Is there a way to optimize the query or it would be better call this query just one time for all the tags?

 

Thanks in advance

Outcomes