Оптимизируй пожалуйста данный Oracle SQL запрос: select ua.id, ua.inn, ua.account,…
- User
Оптимизируй пожалуйста данный Oracle SQL запрос: select ua.id, ua.inn, ua.account, to_char(ua.dt_ins, 'dd.mm.yyyy hh24:mi') dt_ins, ua.user_id, uu.short_fio fio, ua.id_service, ua.id_status, ua.comm, ua.type, ua.lid, uc.value name_lid, case when substr(substr(ua.address, 1, 28), 17) = 'Коми Респ., ' then substr(ua.address, 29) else ua.address end ADDRESS, case when ult.status = 1 then 'tv-yes' when ult.status = 3 then 'tv-message' when ult.status = 2 and ulg.status = 1 then 'germes-yes' when ult.status = 2 then 'tv-error' end STATUS_TV, case when ua.id_status in (1,3) and sysdate - ua.dt_ins > 60 then 1 else 0 end old_activity, uc_service.def service, uc_status.def status, uc_type.def type_work from UL_ACTIVITY ua left join UL_LIST_TV ult on ua.id = ult.id_activity left join UL_LIST_GERMES ulg on ua.id = ulg.id_activity left join UL_CATALOG uc on ua.lid = uc.id_value and uc.id = 8 left join UL_USER uu on uu.id = ua.user_id left join UL_USER uu2 on uu2.id = :oper_id left join UL_CATEGORY uc_service on ua.id_service = uc_service.id and uc_service.category = 'service_activity' left join UL_CATEGORY uc_status on ua.id_status = uc_status.id and uc_status.category = 'status_activity' left join UL_CATEGORY uc_type on ua.type = uc_type.id and uc_type.category = 'type_activity' where ua.inn = :inn and case when ua.plan_dt_install >= trunc(sysdate) then 0 when ua.dt_ins < sysdate - 365 or (round(sysdate - ua.first_dt) > 90 and ua.id_status in (0,1,3) and ua.plan_dt_install is null) then 1 else 0 end = 0 and case when (nvl(ua.lid, 0) <> 11 and (ua.type <> 6 or ua.type is null)) or (ua.lid = 11 and ua.id_status <> 50) or (ua.lid = 11 and ua.id_status = 50 and (ua.user_id = :oper_id or :oper_id in (1, 2, 80, 79, 226, 387))) or (ua.type = 6 and (uu2.id in (1, 39, 80) or uu2.gsp_install = 1)) then 1 else 0 end = 1 order by ua.dt_ins desc
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.