Is there any way to optimize the query below?
SELECT RNC,
CELLNAME,
SUM(C310484605) AS DL_PWR_FAIL,
SUM(C310484607) AS UL_PWR_FAIL,
SUM(C310484609) AS HSDPA_FAIL,
SUM(C310484611) AS HSUPA_FAIL
FROM ZTE_UTRAN.UCELLCAP1
WHERE CELLNAME LIKE '_____B%'
AND DATETIME >=TRUNC(SYSDATE)-7
GROUP BY RNC,
CELLNAME
ORDER BY HSDPA_FAIL DESC
it's taking like hours in execution. Function "sum" is slowing it down but i don't know how to fix it. Any help would be appreciated. thanks in advance.
substr(CELLNAME,5,1) = 'B'instead ofCELLNAME like '_____B%'please adjust the position in substr according to requirementSUMis responsible for performance issues. The vast majority of performance issues are caused by retrieving data and joining it. The time spent in small functions likeSUMis usually irrelevant. How large is the tableUCELLCAP1? Do any of the predicates filter out a large percentage of the data? If so, they might be a good candidate for an index.