In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
CREATE INDEX machine_signal_idx_signal_id_machine_id ON MACHINE_SIGNAL (SIGNAL_ID,MACHINE_ID);
CREATE INDEX tsd_sub_idx_machine_id ON TSD_SUB (MACHINE_SIGNAL_ID);
SELECT
DISTINCT q1.MACHINE_ID,
q1.SIGNAL_ID,
ROUND(86400000 * (REGR_SLOPE(ts.VALUE,
ts.EPOCH) OVER (PARTITION
BY
ts.MACHINE_SIGNAL_ID ))) AS RATE,
q1.LAST_VALUE
FROM
TSD_SUB ts,
(SELECT
ms.MACHINE_SIGNAL_ID,
ms.LAST_TIMESTAMP
FROM
MACHINE_SIGNAL ms
WHERE
(
ms.MACHINE_ID LIKE 'CV%'
)
AND (
ms.SIGNAL_ID = ANY(
'WFRCOUNT', 'WFRCNTR'
)
OR ms.SIGNAL_ID LIKE '%WAFERCT%'
)) q1
WHERE
ts.MACHINE_SIGNAL_ID = q1.MACHINE_SIGNAL_ID
AND ts.EPOCH > (
q1.LAST_TIMESTAMP - 604800000
)