Question

SQL Query execution taking long time to complete

  • 25 January 2024
  • 8 replies
  • 88 views

Badge +5

Hi Everyone,

We have multiple commserve’s available, in one of the commserve when I tried to execute below SQL query to fetch the data it’s taking more than 7 mins to complete where environment is smaller in size. But when I executed the same SQL query in other 6 to 7 commserve environment’s it was completing in 1 Sec only. 

Even I’ve performed the Full DB Maintenance as well, but the issue is still same.

 

Can someone let me know what could be issue here.

 

SQL Query:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

SELECT A.agentId, A.agentName, A.clientId, A.clientName,

    agentStatus =

        CASE

            WHEN A.clientStatus IN ('uninstalled', 'hidden (unknown)') THEN 'uninstalled'

            ELSE A.agentStatus

        END,

    A.agentBkpEnable,  A.agentRstEnable,  A.refTime, A.modified

FROM (

    SELECT

        agentId = iDA.id, agentName = iDAT.name, clientId = iDA.clientId, clientName = C.name,

        clientStatus =

            CASE

                WHEN (C.specialClientFlags & 1) = 1 AND C.id NOT IN (SELECT distinct VMclientId FROM APP_VMProp) THEN 'hidden (unknown)'

                WHEN (C.specialClientFlags & 1) = 1 AND C.id IN (SELECT distinct VMclientId FROM APP_VMProp) THEN 'hidden'

                WHEN CP.attrval = '1' THEN 'uninstalled'

                ELSE 'installed'

            END,

        agentStatus = ISNULL(

            CONVERT(VARCHAR(11), (

                SELECT 'installed'

                FROM APP_IDAName iDA

                WHERE iDA.clientId = C.id

                    AND iDA.appTypeId = iDAT.type

                    AND iDA.status & 2 = 0)),

            'uninstalled'),

        agentBkpEnable =

        CASE ( SELECT JA.action FROM JMJobAction JA WHERE C.id = JA.clientid and JA.apptype = iDAT.type and JA.optype = 4 )

            WHEN 2 THEN CAST(1 AS bit) --True

            --WHEN 1 THEN 0 --NO

            --ELSE NULL

            ELSE CAST(0 AS bit) --False

        END,

        agentRstEnable =

        CASE (SELECT JA.action FROM JMJobAction JA WHERE C.id = JA.clientid and JA.apptype = iDAT.type  and JA.optype = 5)

            WHEN 2 THEN CAST(1 AS bit) --True

            --WHEN 1 THEN 0 --NO

            --ELSE NULL

            ELSE CAST(0 AS bit) --False

        END,

        iDA.refTime,

        iDA.modified

    FROM APP_iDAName iDA

        LEFT JOIN APP_iDAType iDAT ON iDAT.type = iDA.appTypeId

        LEFT JOIN APP_Client C ON C.id = iDA.clientId

        LEFT JOIN APP_ClientProp CP ON C.id = CP.componentNameId AND CP.attrname = 'PlatformDeleted 4' AND CP.modified = 0

) A



 


8 replies

Badge +2

In this case, the best recommendation is to open a ticket with Support.

Userlevel 2
Badge +9

@naraharsha 
Restart SQL service once and check the select Query performance.
And also check the memory allocated for SQL server under the SQL server instance properties  by login onto SQ Studio.

recommend to keep 50% of overall CS server memory reserved for SQL server.

Badge +5

@Pradeep I have performed the restarting the SQL services and memory reserved is also 50% from the server memory. 

Userlevel 2
Badge +9

@naraharsha 
Any progress after making these changes or is it sill the same and could confirm the CS hardware requirements are as per the recommendation.

If these does not work we need to check SQL profiler to understand the details further.

Userlevel 2
Badge +9

@naraharsha could you also share the CS and SQL version installed on site 

Badge +5

@Pradeep 

Here are the spec’s. 
CS - 11.24.65 

SQL - Microsoft SQL Server 2019 (RTM-CU22-GDR) (KB5029378) - 15.0.4326.1 (X64)   Aug 18 2023 14:05:15   Copyright (C) 2019 Microsoft Corporation  Standard Edition (64-bit) on Windows Server 2016 Standard 10.0 <X64> (Build 14393: ) (Hypervisor) 

Userlevel 2
Badge +9

@naraharsha 
SQL is on the latest version However below is the latest patch released kindly update the same and monitor.
https://www.microsoft.com/en-us/download/details.aspx?id=100809
 CU24 - KB5031908

Badge +3

@naraharsha , Can you share the execution plan? That could reveal where exactly it is spending most of its time.

 

Reply