Updated Named Queris and event-scripts
This commit is contained in:
parent
511eedd34f
commit
e6dfda9807
Binary file not shown.
@ -1,5 +1,5 @@
|
|||||||
-- GetActiveAlarmsByLocationAndPriority: Count active alarms grouped by location and priority
|
-- GetActiveAlarmsByLocationAndPriority: Count active alarms grouped by location and priority
|
||||||
-- Uses: idx_alarm_events_active, idx_alarm_events_clear, idx_alarm_event_data_lookup, idx_alarm_events_priority
|
-- Uses: idx_alarm_events_group, idx_alarm_events_clear, idx_alarm_event_data_lookup
|
||||||
-- Expected performance: <100ms on 37K rows, <200ms on 1M+ rows
|
-- Expected performance: <100ms on 37K rows, <200ms on 1M+ rows
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
@ -13,7 +13,7 @@ SELECT
|
|||||||
ELSE 'Unknown'
|
ELSE 'Unknown'
|
||||||
END AS Priority,
|
END AS Priority,
|
||||||
COUNT(*) AS Count
|
COUNT(*) AS Count
|
||||||
FROM alarm_events ae FORCE INDEX (idx_alarm_events_active)
|
FROM alarm_events ae FORCE INDEX (idx_alarm_events_group)
|
||||||
LEFT JOIN alarm_event_data aed FORCE INDEX (idx_alarm_event_data_lookup)
|
LEFT JOIN alarm_event_data aed FORCE INDEX (idx_alarm_event_data_lookup)
|
||||||
ON aed.id = ae.id AND aed.propname = 'myTag'
|
ON aed.id = ae.id AND aed.propname = 'myTag'
|
||||||
WHERE ae.eventtype = 0
|
WHERE ae.eventtype = 0
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
-- MAXIMUM PERFORMANCE: Optimized for EndTimestamp filtering
|
-- MAXIMUM PERFORMANCE: Optimized for EndTimestamp filtering
|
||||||
-- Expected performance: <500ms on 37K rows
|
-- Expected performance: <500ms on 37K rows
|
||||||
-- Params: :starttime (DATETIME), :endtime (DATETIME)
|
-- Params: :starttime (DATETIME), :endtime (DATETIME)
|
||||||
|
-- Uses: idx_alarm_events_type_time_id, idx_alarm_events_clear_agg, idx_alarm_events_eventid_only, idx_alarm_events_clear
|
||||||
|
|
||||||
/*+ MAX_EXECUTION_TIME(8000) */
|
/*+ MAX_EXECUTION_TIME(8000) */
|
||||||
|
|
||||||
@ -30,8 +31,9 @@ SELECT
|
|||||||
FROM alarm_events a FORCE INDEX (idx_alarm_events_type_time_id)
|
FROM alarm_events a FORCE INDEX (idx_alarm_events_type_time_id)
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
-- Find first clear time for each alarm
|
-- Find first clear time for each alarm
|
||||||
|
-- FORCE INDEX on clear_agg optimizes the MIN(eventtime) GROUP BY
|
||||||
SELECT eventid, MIN(eventtime) AS min_clear_time
|
SELECT eventid, MIN(eventtime) AS min_clear_time
|
||||||
FROM alarm_events FORCE INDEX (idx_alarm_events_clear)
|
FROM alarm_events FORCE INDEX (idx_alarm_events_clear_agg)
|
||||||
WHERE eventtype = 1
|
WHERE eventtype = 1
|
||||||
AND eventtime >= :starttime
|
AND eventtime >= :starttime
|
||||||
AND eventtime < :endtime
|
AND eventtime < :endtime
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
-- GetAlarmsWithCount: Alarm statistics with activation counts for a time window
|
-- GetAlarmsWithCount: Alarm statistics with activation counts for a time window
|
||||||
-- Uses: idx_alarm_events_type_time_id, idx_alarm_events_clear, idx_alarm_event_data_lookup
|
-- Uses: idx_alarm_events_type_time_id, idx_alarm_events_clear_agg, idx_alarm_events_eventid_only, idx_alarm_event_data_lookup
|
||||||
-- Expected performance: <300ms on 37K rows, <800ms on 1M+ rows
|
-- Expected performance: <300ms on 37K rows, <800ms on 1M+ rows
|
||||||
-- Params: :startTime (DATETIME or NULL/empty), :endTime (DATETIME or NULL/empty)
|
-- Params: :startTime (DATETIME or NULL/empty), :endTime (DATETIME or NULL/empty)
|
||||||
|
|
||||||
/*+ MAX_EXECUTION_TIME(8000) */
|
/*+ MAX_EXECUTION_TIME(8000) */
|
||||||
|
|
||||||
WITH ClearedEvents AS (
|
WITH ClearedEvents AS (
|
||||||
-- Pre-aggregate clear times - FORCED index usage for speed
|
-- Pre-aggregate clear times - FORCED index for MIN(eventtime) GROUP BY optimization
|
||||||
SELECT
|
SELECT
|
||||||
eventid,
|
eventid,
|
||||||
MIN(eventtime) AS clear_time
|
MIN(eventtime) AS clear_time
|
||||||
FROM alarm_events FORCE INDEX (idx_alarm_events_clear)
|
FROM alarm_events FORCE INDEX (idx_alarm_events_clear_agg)
|
||||||
WHERE eventtype = 1
|
WHERE eventtype = 1
|
||||||
GROUP BY eventid
|
GROUP BY eventid
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user