Hej
Jag har en sql-fråga som är skriven för Sybase SQL-Anywhere 9 som ser ut enligt följande:
SELECT AN.PERSONID, A.GRUPP FROM AKTIVITET AS A
LEFT JOIN GRUPP AS G ON A.GRUPP = G.GRUPP
LEFT JOIN KURS AS K ON G.KURS = K.KURS
LEFT JOIN ANSTALLNING AS AN ON A.SIGNBETYG = AN.SIGN
LEFT JOIN UTBILDNING AS U ON A.PERSONID = U.PERSONID
WHERE A.ENHET = 'XX'
AND U.ENHET = 'XX'
AND (U.STOPPDATUM IS NULL OR U.STOPPDATUM > GETDATE())
AND A.STARTDATUM <= GETDATE()-10
AND A.STOPPDATUM >= GETDATE()+10
AND AN.PERSONID IS NOT NULL
AND A.GRUPP IS NOT NULL
GROUP BY AN.PERSONID, A.GRUPP
Den tar dock väldigt väldigt lång tid att köra. Finns det något sätt jag kan snabba upp den på?
Execution plan ger följande resultat
Node Statistics
*
Estimates
*
Description
*
RowsReturned1.5256
Number of rows returned
PercentTotalCost99.985
Run time as a percent of total query time
RunTime0.40253
Time to compute the results
CPUTime0.16925
Time required by CPU
DiskReadTime0.23328
Time to perform reads from disk
DiskWriteTime0
Time to perform writes to disk
DiskRead194.4
Disk reads
DiskWrite0
Disk writes
Subtree Statistics
*
Estimates
*
Description
*
RowsReturned1.5256
Number of rows returned
PercentTotalCost100
Run time as a percent of total query time
RunTime0.40259
Time to compute the results
CPUTime0.16931
Time required by CPU
DiskReadTime0.23328
Time to perform reads from disk
DiskWriteTime0
Time to perform writes to disk
DiskRead194.4
Disk reads
DiskWrite0
Disk writes
Optimizer statistics
*
Value
*
Description
*
Costed subplans14
Number of different enumeration strategies considered by the optimizer
Estimated cache pages64009
Estimated cache pages available for this statement
CurrentCacheSize523788
Current cache size in kilobytes
Isolation_level0
Controls the locking isolation level
Optimization_goalAll-rows
Optimize queries for first row or all rows
Optimization_level9
Reserved
Optimization_workloadMixed
Controls whether optimizing for OLAP or mixed queries
ProductVersion9.0.2.2451
Product version
User_estimatesOverride-magic
Controls whether to respect user estimates
Select list
AN.PERSONIDchar(11)
A.GRUPPchar(20)