Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
I recently reviewed a gather info report from a site which has a around 1000 registered users and a peak concurrency of around 100 users a day. The SQL statement below stuck out like a sore thumb in the report as needing to be tuned; it was the last statement in both the "Report End: Worst Total SQL by CPU Time" & "Report End: Worst SQL By Factor" sections of the the report.txt file. The statement had been executed more than 1500 times, with an average elapsed time of 11 seconds for each execution. The statement had a cumulative elapsed time of 17,535 seconds which was almost five hours users of the system spent waiting for this one statement to complete. But the statement only had a CPU time of 1,118 seconds suggesting there was a significant delay which on analysis was determined to be 40 million disk I/O reads. Any statement that performs excessive disk I/O reads inhibits the overall system scalability in two ways:
When looking to improve the performance of a SQL statement several things to initially consider are:
In this case I suspected since there was only one table in the FROM clause the index would likely fall into the first category of reducing disk I/O, if there been only a few columns in the 'select' part of the statement adding the second type of index might be worth considering. If the right index had existed for this statement (which it didn't) and was then not being used, it's possible the third type of index would have been considered.
In this case as in most cases when I tuning a SQL initial statement the steps I followed for a statement are:
SQL Statement to tune:
Select 'wt.epm.EPMDocConfigSpec',A0.administrativeLockIsNull,A0.typeadministrativeLock,A0.asStoredActive,A0.asStoredConfig,
A0.baselineIsNull,A0.classnamekeyA2A5,A0.idA3A2A5,A0.baselineActive,A0.blob$asStoredConfig,A0.blob$sandboxConfig,A0.classnamekeydomainRef,
A0.idA3domainRef,A0.effectivityIsNull,A0.effectiveConfigItemRefIsNull,A0.classnamekeyA2D5,A0.idA3A2D5,TO_CHAR(A0.effectiveDateD5,'dd mm yyyy hh24:mi:ss'),
A0.effectiveUnitD5,A0.effectivityActive,A0.eventSet,A0.folderedIsNull,A0.classnamekeyA2C5,A0.idA3A2C5,A0.folderedActive,A0.inheritedDomain,A0.lifeCycleIsNull,
A0.lifeCycleStateB5,A0.lifeCycleActive,A0.classnamekeyA2ownership,A0.idA3A2ownership,A0.promotionNoticeIsNull,A0.baselineConfigSpecIsNullE5,A0.classnamekeyA2A2E5,
A0.idA3A2A2E5,A0.classnamekeyB2E5,A0.idA3B2E5,A0.promotionNoticeActive,A0.sandboxActive,A0.sandboxConfig,A0.securityLabels,TO_CHAR(A0.createStampA2,'dd mm yyyy hh24:mi:ss'),
A0.markForDeleteA2,TO_CHAR(A0.modifyStampA2,'dd mm yyyy hh24:mi:ss'),A0.idA2A2,A0.updateCountA2,TO_CHAR(A0.updateStampA2,'dd mm yyyy hh24:mi:ss'),A0.workingIncluded
FROM EPMDocConfigSpec A0
WHERE ((A0.idA3A2A5 = :1 ))
AND (A0.markForDeleteA2 =0)
Indexes Available:
TABLE_NAME INDEX_NAME COLUMN_NAME COLUMN_POSITION DISTINCT_KEYS
------------------------------ ------------------------------ ------------ --------------- -------------
EPMDOCCONFIGSPEC PK_EPMDOCCONFIGSPEC IDA2A2 1 392344
Table Statistics:
TABLE_NAME | COLUMN_NAME | NUM_DISTINCT | DENSITY | NUM_NULLS |
------------------------------ | -------------------------------- | ------------ | ---------- | ---------- |
EPMDOCCONFIGSPEC | ASSTOREDACTIVE | 2 | 0.5 | 0 |
EPMDOCCONFIGSPEC | ASSTOREDCONFIG | 146880 | 6.81E-06 | 93516 |
EPMDOCCONFIGSPEC | BASELINEACTIVE | 2 | 0.5 | 0 |
EPMDOCCONFIGSPEC | BASELINEISNULL | 1 | 1 | 360562 |
EPMDOCCONFIGSPEC | CLASSNAMEA2A2 | 1 | 1 | 0 |
EPMDOCCONFIGSPEC | CLASSNAMEKEYA2A5 | 2 | 0.5 | 360562 |
EPMDOCCONFIGSPEC | CLASSNAMEKEYA2C5 | 1 | 1 | 389118 |
EPMDOCCONFIGSPEC | CLASSNAMEKEYDOMAINREF | 1 | 1 | 0 |
EPMDOCCONFIGSPEC | CREATESTAMPA2 | 358016 | 2.79E-06 | 0 |
EPMDOCCONFIGSPEC | EFFECTIVEDATED5 | 110 | 0.009090909 | 389118 |
EPMDOCCONFIGSPEC | EFFECTIVITYACTIVE | 1 | 1 | 0 |
EPMDOCCONFIGSPEC | EFFECTIVITYISNULL | 1 | 1 | 389118 |
EPMDOCCONFIGSPEC | FOLDEREDACTIVE | 1 | 1 | 0 |
EPMDOCCONFIGSPEC | FOLDEREDISNULL | 1 | 1 | 389118 |
EPMDOCCONFIGSPEC | IDA2A2 | 392344 | 2.55E-06 | 0 |
EPMDOCCONFIGSPEC | IDA3A2A5 | 13770 | 0.000072622 | 360562 |
EPMDOCCONFIGSPEC | IDA3A2C5 | 4 | 0.25 | 389118 |
EPMDOCCONFIGSPEC | IDA3A2OWNERSHIP | 1 | 1 | 0 |
EPMDOCCONFIGSPEC | IDA3DOMAINREF | 25 | 0.04 | 0 |
EPMDOCCONFIGSPEC | INHERITEDDOMAIN | 1 | 1 | 0 |
EPMDOCCONFIGSPEC | LIFECYCLEACTIVE | 2 | 0.5 | 0 |
EPMDOCCONFIGSPEC | LIFECYCLEISNULL | 1 | 1 | 389114 |
EPMDOCCONFIGSPEC | LIFECYCLESTATEB5 | 2 | 0.5 | 389114 |
EPMDOCCONFIGSPEC | MARKFORDELETEA2 | 1 | 1.29E-06 | 0 |
EPMDOCCONFIGSPEC | MODIFYSTAMPA2 | 358080 | 2.79E-06 | 0 |
EPMDOCCONFIGSPEC | PROMOTIONNOTICEACTIVE | 1 | 1 | 0 |
EPMDOCCONFIGSPEC | SANDBOXACTIVE | 2 | 0.5 | 0 |
EPMDOCCONFIGSPEC | SANDBOXCONFIG | 2 | 0.5 | 392342 |
EPMDOCCONFIGSPEC | UPDATECOUNTA2 | 6 | 1.29E-06 | 0 |
EPMDOCCONFIGSPEC | UPDATESTAMPA2 | 358080 | 2.79E-06 | 0 |
EPMDOCCONFIGSPEC | WORKINGINCLUDED | 1 | 1 | 0 |