This query is PAINFULLY slow and our team cannot figure out why. We've tried creating views, but it still extremely slow. Any thoughts?
SELECT
CI . CWARCASNBR AS CASENUMBER ,
CI . CT1FYA AS COURTAGENCYCODE ,
CI . CIPTYSQNBR AS PARTYSEQNBR ,
CI . CIRCDTYPE AS CASETYPECODE ,
CP . NMELASTBUS AS LASTNAME ,
CP . NAME_FIRST AS FIRSTNAME ,
CP . NAME_MID AS MIDDLENAME ,
CP . NAME_SUFFX AS SUFFIX ,
CP . CP_SEX AS GENDER ,
CP . CT1PA AS RACECODE ,
CP . CP_DOB AS DOB ,
CP . CP_SSN AS SSN ,
A . STREETNAME AS ADDRESS1 ,
A . ADDRLINE2 AS ADDRESS2 ,
A . CITYPARISH AS CITY ,
A . ADDRSTATE AS STATE ,
A . ZIPCODE AS ZIP
FROM
CMSDPL23 . JE026001 AS CP
LEFT OUTER JOIN
CMSDPR23 . JE215000 CI ON
CP . JEBOA = CI . CWARCASNBR AND
CP . CT1FYA = CI . CT1FYA AND
CP . CP_SEQ_NBR = CI . CIPTYSQNBR
LEFT OUTER JOIN
CMSDPR23 . CT007000 A ON CP . ADDRESSID = A . ADDRESSID
AND CP . ADDRESSPRI = A . ADDIDSEQNO
WHERE
CP . NMELASTBUS LIKE 'Durham' || '%' AND
CP . NAME_FIRST LIKE 'Roger%' || '%' AND
NOT CP . PRTY_TCDE IN ( 'OFF' , 'BEP' ) AND
CI . CI_FLAG_1 IN ( 'C' , 'B' ) AND
CI . CT1MKA = '23'
ORDER BY
CI . CWARCASNBR , CI . CT1FYA ;