以下のコードは実行に時間がかかりすぎています。私はそれがコードであることを知っています:
case when (select (concat(alias,' - ',firm))
from publiccontact where replace(replace(replace(replace(businessnumber,'+44 (','0'),') ',''),'+44','0'),')','') = tax.callerid1 and businessnumber <> ''
limit 1
) is not null then
(select (concat(alias,' - ',firm))
from publiccontact where replace(replace(replace(replace(businessnumber,'+44 (','0'),') ',''),'+44','0'),')','') = tax.callerid1 and businessnumber <> ''
limit 1
) else (select (concat(alias,' - ',firm))
from publiccontact where replace(replace(replace(replace(mobilenumber,'+44 (','0'),') ',''),'+44','0'),')','') = tax.callerid1 and mobilenumber <> ''
limit 1
)
end as callername,
私のケースとサブ選択をより効率的にすることはできますか?私のコードは機能しますが、間違いなく効率的ではありません。
select date(instime) as date,
Pkey as ID,
subscriber as user,
SUBSCRIBERNAME as userName,
case when (select (concat(alias,' - ',firm))
from publiccontact where replace(replace(replace(replace(businessnumber,'+44 (','0'),') ',''),'+44','0'),')','') = tax.callerid1 and businessnumber <> ''
limit 1
) is not null then
(select (concat(alias,' - ',firm))
from publiccontact where replace(replace(replace(replace(businessnumber,'+44 (','0'),') ',''),'+44','0'),')','') = tax.callerid1 and businessnumber <> ''
limit 1
) else (select (concat(alias,' - ',firm))
from publiccontact where replace(replace(replace(replace(mobilenumber,'+44 (','0'),') ',''),'+44','0'),')','') = tax.callerid1 and mobilenumber <> ''
limit 1
)
end as callername,
(select (concat(alias,' - ',firm))
from publiccontact where replace(replace(replace(replace(businessnumber,'+44 (','0'),') ',''),'+44','0'),')','') = tax.destinationnumber1 and businessnumber <> ''
limit 1
)
as destinationname,
case when direction = 1 then 'incoming' else 'outgoing' end as direction,
case when CALLDESTINATION = 1 then 'public' else 'private' end as destination,
startdate as StartDate,
starttime as StartTime,
duration as DuractionSec,
TIMETOANSWER as TimeAnswerSec,
TAXCHARGES as Charges,
coalesce(callerid1,callerid2,'') as CallerID,
coalesce(destinationnumber1,destinationnumber2,'') as DestinationNumber,
ORIGINSUBSCRIBER as UserNumber,
completed as CallCompleted,
coalesce(case when concat(DIRECTION,CALLDESTINATION,CALLTYPE,CALLHANDLING) = 2123 then 'Incoming Call Transfered External' else null end,
case when concat(DIRECTION,CALLDESTINATION,CALLTYPE,CALLHANDLING) = 1132 then 'Incoming Call Transfered External' else null end,
case when concat(DIRECTION,CALLDESTINATION,CALLTYPE,CALLHANDLING) = 1131 then 'Incoming Call Transfered Interal' else null end,
case when concat(DIRECTION,CALLDESTINATION,CALLTYPE,CALLHANDLING) = 1132 then 'Incoming Call Transfered Interal' else null end,
case when concat(DIRECTION,CALLDESTINATION,CALLTYPE,CALLHANDLING) = 1233 then 'AMC Call Answered' else null end,
case when concat(DIRECTION,CALLDESTINATION,CALLTYPE,CALLHANDLING) = 2122 then 'Incoming DDI call answered by GSM' else null end,
case when concat(DIRECTION,CALLDESTINATION,CALLTYPE,CALLHANDLING) = 1232 then 'AMCOutgoing' else null end,
case when concat(DIRECTION,CALLDESTINATION,CALLTYPE,CALLHANDLING) = 2111 then 'OutgoingCallTransferedInternally' else null end,
case when concat(DIRECTION,CALLDESTINATION,CALLTYPE,CALLHANDLING) = 2121 then 'OutgoingCallTransferedInternally' else null end,
case when concat(DIRECTION,CALLDESTINATION,CALLTYPE,CALLHANDLING) = 2123 then 'OutgoingCallTransferedtoExternal' else null end,
case when concat(DIRECTION,CALLDESTINATION,CALLTYPE,CALLHANDLING) = 1252 then 'IncomingCallPrivateNetworkCallShouldBeIgnored' else null end,
case when concat(DIRECTION,CALLDESTINATION,CALLTYPE,CALLHANDLING) = 1143 then 'IncACDCallUnaws' else null end,
case when concat(DIRECTION,CALLDESTINATION,CALLTYPE,CALLHANDLING) = 1142 then 'IncACDCallAnswered' else null end,'') as type
from taxticketitem tax;
敬具