Вот простенький SQL (у мeня их несколько от последней миграции, так что не соскучимся) который мы совсем недавно выявили и попросили обратиьть на него внимание разработчиков. Прочитайте и Вы, iDesperado, этот SQL с умением и рассказы что было в нем не так и что разработчики в итоге сдеали с ним. Спасибо.
Code: Select all
SELECT WOTSK.FACILITY , WOTSK.UNIT , WOTSK.INTERRUPT
, WOTSK.SHUTDOWN_NBR , WOTSK.WORK_ORDER_NBR
, WOTSK.WORK_ORDER_TASK , WOTSK.TASK_SEQUENCE
, WOTSK.WO_TSK_STATUS
, WOTSK.WO_TSK_PRIORITY
, WOTSK.NEED_DATE , WOTSK.WR_TASK_TITLE
FROM AS07DADM.TIDWOTSK WOTSK
WHERE ( WOTSK.WORK_ORDER_NBR BETWEEN ? AND ? )
AND ( EXISTS ( SELECT 1 FROM AS07DADM.TIDWOTSK WOTS1
WHERE ( WOTS1.WORK_ORDER_NBR = WOTSK.WORK_ORDER_NBR )
AND ( WOTS1.WORK_ORDER_TASK = WOTSK.WORK_ORDER_TASK )
AND ( ( WOTS1.FACILITY = ? ) OR ( 1 = 0 ) )
AND ( ( WOTS1 .UNIT BETWEEN ? AND ? ) OR ( 1 = 0 ) )
AND ( ( WOTS1.WO_TSK_STATUS = '45' )
OR ( WOTS1.WO_TSK_STATUS = '48' ) )
) OR ( 1 = 0 )
)
AND ( ( WOTSK.WORK_ORDER_NBR || WOTSK.WORK_ORDER_TASK
BETWEEN ? AND ? ) OR ( 1 = 0 ) )
ORDER BY WOTSK.WORK_ORDER_NBR DESC
, WOTSK.WORK_ORDER_TASK DESC;
Code: Select all
CREATE UNIQUE INDEX TIIWOTSK ON TIDWOTSK
(
WORK_ORDER_NBR DESC, 0533
WORK_ORDER_TASK DESC 0299
)
....
CREATE UNIQUE INDEX TIIWOTS1 ON TIDWOTSK
(
FACILITY, 0533
UNIT, 0533
SYSTEM_CODE, 0533
EQUIPMENT_TYPE, 0533
EQUIPMENT_NUMBER, 0533
DISCIPLINE, 0533
WORK_ORDER_NBR, 0533
WORK_ORDER_TASK, 0533
WO_TSK_STATUS 0533
)
...
CREATE INDEX TIIWOTS2 ON TIDWOTSK
(
UTC_NUMBER
)
....
CREATE INDEX TIIWOTS3 ON TIDWOTSK
(
E_CODE,
WORK_ORDER_NBR,
WO_TSK_STATUS 0533
)
...
CREATE INDEX TIIWOTS4 ON TIDWOTSK
(
WORK_ORDER_NBR,
WORK_ORDER_TASK, 0533
WO_TSK_STATUS,
NEED_DATE,
WORK_ORDER_TYPE,
UNIT, 0533
SYSTEM_CODE, 0533
DISCIPLINE,
WO_TSK_PRIORITY
)
....
CREATE UNIQUE INDEX TIIWOTS5 ON TIDWOTSK
(
KEY_REF_NBR,
KEY_REF_SUB_NBR,
KEY_REF_TYPE
)
...
CREATE INDEX TIIWOTS6 ON TIDWOTSK
(
LOCATION_ID,
LOCATION_REGION,
WORK_ORDER_NBR
)
....
CREATE INDEX TIIWOTS7 ON TIDWOTSK
(
REFERENCE_TYPE,
REFERENCE_NBR
)
...
CREATE UNIQUE INDEX TIIWOTS9 ON TIDWOTSK
(
FACILITY,
WORK_ORDER_NBR,
WORK_ORDER_TASK
)
.....
CREATE INDEX TIIWOTSA ON TIDWOTSK
(
CLIENT_ID
)
..............
CREATE INDEX TIIWOTSB ON TIDWOTSK
(
CATALOG_ID,
Q_LEVEL,
FACILITY
)