HANA Workload AdmissionControlEvents 2.00.010+
HANA Workload AdmissionControlEvents 2.00.010+
HANA Workload AdmissionControlEvents 2.00.010+
/*
[NAME]
- HANA_Workload_AdmissionControlEvents_2.00.010+
[DESCRIPTION]
[SOURCE]
[VALID FOR]
[INVOLVED TABLES]
- M_ADMISSION_CONTROL_EVENTS
[INPUT PARAMETERS]
- BEGIN_TIME
Begin time
'2018/12/05 14:05:00' --> Set begin time to 5th of December 2018, 14:05
'C' --> Set begin time to current time
'C-S900' --> Set begin time to current time minus 900 seconds
'C-M15' --> Set begin time to current time minus 15 minutes
'C-H5' --> Set begin time to current time minus 5 hours
'C-D1' --> Set begin time to current time minus 1 day
'C-W4' --> Set begin time to current time minus 4 weeks
'E-S900' --> Set begin time to end time minus 900 seconds
'E-M15' --> Set begin time to end time minus 15 minutes
'E-H5' --> Set begin time to end time minus 5 hours
'E-D1' --> Set begin time to end time minus 1 day
'E-W4' --> Set begin time to end time minus 4 weeks
'MIN' --> Set begin time to minimum (1000/01/01 00:00:00)
- END_TIME
End time
'2018/12/08 14:05:00' --> Set end time to 8th of December 2018, 14:05
'C' --> Set end time to current time
'C-S900' --> Set end time to current time minus 900 seconds
'C-M15' --> Set end time to current time minus 15 minutes
'C-H5' --> Set end time to current time minus 5 hours
'C-D1' --> Set end time to current time minus 1 day
'C-W4' --> Set end time to current time minus 4 weeks
'B+S900' --> Set end time to begin time plus 900 seconds
'B+M15' --> Set end time to begin time plus 15 minutes
'B+H5' --> Set end time to begin time plus 5 hours
'B+D1' --> Set end time to begin time plus 1 day
'B+W4' --> Set end time to begin time plus 4 weeks
'MAX' --> Set end time to maximum (9999/12/31 23:59:59)
- TIMEZONE
- HOST
Host name
- PORT
Port number
- CONN_ID
Connection ID
- STATEMENT_HASH
- EVENT_TYPE
- EVENT_REASON
'EXCEEDED QUEUE WAIT TIME THRESHOLD%' --> Only show event reasons starting with
'EXCEEDED QUEUE WAIT TIME THRESHOLD'
'%' --> No restriction related to event reason
- MESSAGE_TYPE
- AGGREGATE_BY
- TIME_AGGREGATE_BY
- ORDER_BY
[OUTPUT PARAMETERS]
- EVENT_TIME:
- HOST: Host
- PORT: Port
- COUNT: Number of database requests
- CONN_ID: Connection ID
- STATEMENT_HASH: Statement hash
- EVENT_TYPE: Event type
- EVENT_REASON: Event reason
- MESSAGE_TYPE: Message type (similar to thread method)
- QUEUED_S: (max.) queue wait time (s)
- CPU_PCT: (max.) CPU utilization (%)
- MEM_RATIO: (max.) Memory utilization (%)
[EXAMPLE OUTPUT]
-----------------------------------------------------------------------------------
--------------------
|EVENT_TIME |COUNT |EVENT_TYPE|EVENT_REASON |
QUEUED_S |CPU_PCT|MEM_PCT|
-----------------------------------------------------------------------------------
--------------------
|2018/06/04 11| 628|QUEUE |EXCEEDED QUEUE WAIT TIME THRESHOLD 100000|
13.05| 64| 68|
|2018/06/04 10| 686|QUEUE |EXCEEDED QUEUE WAIT TIME THRESHOLD 100000|
13.88| 64| 68|
-----------------------------------------------------------------------------------
--------------------
*/
EVENT_TIME,
HOST,
LPAD(PORT, 5) PORT,
LPAD(COUNT, 8) COUNT,
CONN_ID,
STATEMENT_HASH,
EVENT_TYPE,
EVENT_REASON,
MESSAGE_TYPE,
LPAD(TO_DECIMAL(QUEUE_WAIT_TIME_MS / 1000, 10, 2), 9) QUEUED_S,
LPAD(CPU_USAGE_RATIO, 7) CPU_PCT,
LPAD(MEMORY_RATIO, 7) MEM_PCT
FROM
( SELECT
CASE
WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'TIME') != 0 THEN
CASE
WHEN BI.TIME_AGGREGATE_BY LIKE 'TS%' THEN
TO_VARCHAR(ADD_SECONDS(TO_TIMESTAMP('2014/01/01 00:00:00', 'YYYY/MM/DD
HH24:MI:SS'), FLOOR(SECONDS_BETWEEN(TO_TIMESTAMP('2014/01/01 00:00:00',
'YYYY/MM/DD HH24:MI:SS'), CASE BI.TIMEZONE WHEN 'UTC' THEN
ADD_SECONDS(A.EVENT_TIME, SECONDS_BETWEEN(CURRENT_TIMESTAMP, CURRENT_UTCTIMESTAMP))
ELSE A.EVENT_TIME END) / SUBSTR(BI.TIME_AGGREGATE_BY, 3)) *
SUBSTR(BI.TIME_AGGREGATE_BY, 3)), 'YYYY/MM/DD HH24:MI:SS')
ELSE TO_VARCHAR(CASE BI.TIMEZONE WHEN 'UTC' THEN
ADD_SECONDS(A.EVENT_TIME, SECONDS_BETWEEN(CURRENT_TIMESTAMP, CURRENT_UTCTIMESTAMP))
ELSE A.EVENT_TIME END, BI.TIME_AGGREGATE_BY)
END
ELSE 'any'
END EVENT_TIME,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'HOST') !=
0 THEN A.HOST ELSE MAP(BI.HOST, '%', 'any', BI.HOST)
END HOST,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'PORT') !=
0 THEN TO_VARCHAR(A.PORT) ELSE MAP(BI.PORT, '%', 'any', BI.PORT)
END PORT,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'CONN_ID') !=
0 THEN TO_VARCHAR(A.CONNECTION_ID) ELSE MAP(BI.CONN_ID, -1, 'any',
TO_VARCHAR(BI.CONN_ID)) END CONN_ID,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'HASH') !=
0 THEN A.STATEMENT_HASH ELSE MAP(BI.STATEMENT_HASH, '%', 'any',
BI.STATEMENT_HASH) END STATEMENT_HASH,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'EVENT_TYPE') !=
0 THEN A.EVENT_TYPE ELSE MAP(BI.EVENT_TYPE, '%', 'any',
BI.EVENT_TYPE) END EVENT_TYPE,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'EVENT_REASON') !=
0 THEN A.EVENT_REASON ELSE MAP(BI.EVENT_REASON, '%', 'any',
BI.EVENT_REASON) END EVENT_REASON,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'MESSAGE_TYPE') !=
0 THEN A.MESSAGE_TYPE ELSE MAP(BI.MESSAGE_TYPE, '%', 'any',
BI.MESSAGE_TYPE) END MESSAGE_TYPE,
COUNT(*) COUNT,
MAX(A.QUEUE_WAIT_TIME / 1000) QUEUE_WAIT_TIME_MS,
MAX(A.CPU_USAGE_RATIO) CPU_USAGE_RATIO,
MAX(A.MEMORY_RATIO) MEMORY_RATIO,
BI.ORDER_BY
FROM
( SELECT
CASE
WHEN BEGIN_TIME = 'C' THEN CURRENT_TIMESTAMP
WHEN BEGIN_TIME LIKE 'C-S%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(BEGIN_TIME, 'C-S'))
WHEN BEGIN_TIME LIKE 'C-M%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(BEGIN_TIME, 'C-M') * 60)
WHEN BEGIN_TIME LIKE 'C-H%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(BEGIN_TIME, 'C-H') * 3600)
WHEN BEGIN_TIME LIKE 'C-D%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(BEGIN_TIME, 'C-D') * 86400)
WHEN BEGIN_TIME LIKE 'C-W%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(BEGIN_TIME, 'C-W') * 86400 * 7)
WHEN BEGIN_TIME LIKE 'E-S%' THEN
ADD_SECONDS(TO_TIMESTAMP(END_TIME, 'YYYY/MM/DD HH24:MI:SS'),
-SUBSTR_AFTER(BEGIN_TIME, 'E-S'))
WHEN BEGIN_TIME LIKE 'E-M%' THEN
ADD_SECONDS(TO_TIMESTAMP(END_TIME, 'YYYY/MM/DD HH24:MI:SS'),
-SUBSTR_AFTER(BEGIN_TIME, 'E-M') * 60)
WHEN BEGIN_TIME LIKE 'E-H%' THEN
ADD_SECONDS(TO_TIMESTAMP(END_TIME, 'YYYY/MM/DD HH24:MI:SS'),
-SUBSTR_AFTER(BEGIN_TIME, 'E-H') * 3600)
WHEN BEGIN_TIME LIKE 'E-D%' THEN
ADD_SECONDS(TO_TIMESTAMP(END_TIME, 'YYYY/MM/DD HH24:MI:SS'),
-SUBSTR_AFTER(BEGIN_TIME, 'E-D') * 86400)
WHEN BEGIN_TIME LIKE 'E-W%' THEN
ADD_SECONDS(TO_TIMESTAMP(END_TIME, 'YYYY/MM/DD HH24:MI:SS'),
-SUBSTR_AFTER(BEGIN_TIME, 'E-W') * 86400 * 7)
WHEN BEGIN_TIME = 'MIN' THEN
TO_TIMESTAMP('1000/01/01 00:00:00', 'YYYY/MM/DD HH24:MI:SS')
WHEN SUBSTR(BEGIN_TIME, 1, 1) NOT IN ('C', 'E', 'M') THEN
TO_TIMESTAMP(BEGIN_TIME, 'YYYY/MM/DD HH24:MI:SS')
END BEGIN_TIME,
CASE
WHEN END_TIME = 'C' THEN CURRENT_TIMESTAMP
WHEN END_TIME LIKE 'C-S%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(END_TIME, 'C-S'))
WHEN END_TIME LIKE 'C-M%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(END_TIME, 'C-M') * 60)
WHEN END_TIME LIKE 'C-H%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(END_TIME, 'C-H') * 3600)
WHEN END_TIME LIKE 'C-D%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(END_TIME, 'C-D') * 86400)
WHEN END_TIME LIKE 'C-W%' THEN
ADD_SECONDS(CURRENT_TIMESTAMP, -SUBSTR_AFTER(END_TIME, 'C-W') * 86400 * 7)
WHEN END_TIME LIKE 'B+S%' THEN
ADD_SECONDS(TO_TIMESTAMP(BEGIN_TIME, 'YYYY/MM/DD HH24:MI:SS'),
SUBSTR_AFTER(END_TIME, 'B+S'))
WHEN END_TIME LIKE 'B+M%' THEN
ADD_SECONDS(TO_TIMESTAMP(BEGIN_TIME, 'YYYY/MM/DD HH24:MI:SS'),
SUBSTR_AFTER(END_TIME, 'B+M') * 60)
WHEN END_TIME LIKE 'B+H%' THEN
ADD_SECONDS(TO_TIMESTAMP(BEGIN_TIME, 'YYYY/MM/DD HH24:MI:SS'),
SUBSTR_AFTER(END_TIME, 'B+H') * 3600)
WHEN END_TIME LIKE 'B+D%' THEN
ADD_SECONDS(TO_TIMESTAMP(BEGIN_TIME, 'YYYY/MM/DD HH24:MI:SS'),
SUBSTR_AFTER(END_TIME, 'B+D') * 86400)
WHEN END_TIME LIKE 'B+W%' THEN
ADD_SECONDS(TO_TIMESTAMP(BEGIN_TIME, 'YYYY/MM/DD HH24:MI:SS'),
SUBSTR_AFTER(END_TIME, 'B+W') * 86400 * 7)
WHEN END_TIME = 'MAX' THEN
TO_TIMESTAMP('9999/12/31 00:00:00', 'YYYY/MM/DD HH24:MI:SS')
WHEN SUBSTR(END_TIME, 1, 1) NOT IN ('C', 'B', 'M') THEN
TO_TIMESTAMP(END_TIME, 'YYYY/MM/DD HH24:MI:SS')
END END_TIME,
TIMEZONE,
HOST,
PORT,
CONN_ID,
STATEMENT_HASH,
EVENT_TYPE,
EVENT_REASON,
MESSAGE_TYPE,
AGGREGATE_BY,
MAP(TIME_AGGREGATE_BY,
'NONE', 'YYYY/MM/DD HH24:MI:SS',
'HOUR', 'YYYY/MM/DD HH24',
'DAY', 'YYYY/MM/DD (DY)',
'HOUR_OF_DAY', 'HH24',
TIME_AGGREGATE_BY ) TIME_AGGREGATE_BY,
ORDER_BY
FROM
( SELECT /* Modification section */
'1000/10/18 07:58:00' BEGIN_TIME, /* YYYY/MM/DD HH24:MI:SS
timestamp, C, C-S<seconds>, C-M<minutes>, C-H<hours>, C-D<days>, C-W<weeks>, E-
S<seconds>, E-M<minutes>, E-H<hours>, E-D<days>, E-W<weeks>, MIN */
'9999/10/18 08:05:00' END_TIME, /* YYYY/MM/DD HH24:MI:SS
timestamp, C, C-S<seconds>, C-M<minutes>, C-H<hours>, C-D<days>, C-W<weeks>,
B+S<seconds>, B+M<minutes>, B+H<hours>, B+D<days>, B+W<weeks>, MAX */
'SERVER' TIMEZONE, /* SERVER, UTC */
'%' HOST,
'%' PORT,
-1 CONN_ID,
'%' STATEMENT_HASH,
'%' EVENT_TYPE,
'%' EVENT_REASON,
'%' MESSAGE_TYPE,
'TIME' AGGREGATE_BY, /* HOST, PORT, TIME, CONN_ID, HASH,
EVENT_TYPE, EVENT_REASON, MESSAGE_TYPE or comma separated combination, NONE for no
aggregation */
'NONE' TIME_AGGREGATE_BY, /* HOUR, DAY, HOUR_OF_DAY or database time
pattern, TS<seconds> for time slice, NONE for no aggregation */
'TIME' ORDER_BY /* TIME, COUNT, EVENT */
FROM
DUMMY
)
) BI,
M_ADMISSION_CONTROL_EVENTS A
WHERE
CASE BI.TIMEZONE WHEN 'UTC' THEN ADD_SECONDS(A.EVENT_TIME,
SECONDS_BETWEEN(CURRENT_TIMESTAMP, CURRENT_UTCTIMESTAMP)) ELSE A.EVENT_TIME END
BETWEEN BI.BEGIN_TIME AND BI.END_TIME AND
A.HOST LIKE BI.HOST AND
TO_VARCHAR(A.PORT) LIKE BI.PORT AND
( BI.CONN_ID = -1 OR A.CONNECTION_ID = BI.CONN_ID ) AND
A.STATEMENT_HASH LIKE BI.STATEMENT_HASH AND
A.EVENT_TYPE LIKE BI.EVENT_TYPE AND
A.EVENT_REASON LIKE BI.EVENT_REASON AND
A.MESSAGE_TYPE LIKE BI.MESSAGE_TYPE
GROUP BY
CASE
WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'TIME') != 0 THEN
CASE
WHEN BI.TIME_AGGREGATE_BY LIKE 'TS%' THEN
TO_VARCHAR(ADD_SECONDS(TO_TIMESTAMP('2014/01/01 00:00:00', 'YYYY/MM/DD
HH24:MI:SS'), FLOOR(SECONDS_BETWEEN(TO_TIMESTAMP('2014/01/01 00:00:00',
'YYYY/MM/DD HH24:MI:SS'), CASE BI.TIMEZONE WHEN 'UTC' THEN
ADD_SECONDS(A.EVENT_TIME, SECONDS_BETWEEN(CURRENT_TIMESTAMP, CURRENT_UTCTIMESTAMP))
ELSE A.EVENT_TIME END) / SUBSTR(BI.TIME_AGGREGATE_BY, 3)) *
SUBSTR(BI.TIME_AGGREGATE_BY, 3)), 'YYYY/MM/DD HH24:MI:SS')
ELSE TO_VARCHAR(CASE BI.TIMEZONE WHEN 'UTC' THEN
ADD_SECONDS(A.EVENT_TIME, SECONDS_BETWEEN(CURRENT_TIMESTAMP, CURRENT_UTCTIMESTAMP))
ELSE A.EVENT_TIME END, BI.TIME_AGGREGATE_BY)
END
ELSE 'any'
END,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'HOST') !=
0 THEN A.HOST ELSE MAP(BI.HOST, '%', 'any', BI.HOST)
END,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'PORT') !=
0 THEN TO_VARCHAR(A.PORT) ELSE MAP(BI.PORT, '%', 'any', BI.PORT)
END,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'CONN_ID') !=
0 THEN TO_VARCHAR(A.CONNECTION_ID) ELSE MAP(BI.CONN_ID, -1, 'any',
TO_VARCHAR(BI.CONN_ID)) END,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'HASH') !=
0 THEN A.STATEMENT_HASH ELSE MAP(BI.STATEMENT_HASH, '%', 'any',
BI.STATEMENT_HASH) END,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'EVENT_TYPE') !=
0 THEN A.EVENT_TYPE ELSE MAP(BI.EVENT_TYPE, '%', 'any',
BI.EVENT_TYPE) END,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'EVENT_REASON') !=
0 THEN A.EVENT_REASON ELSE MAP(BI.EVENT_REASON, '%', 'any',
BI.EVENT_REASON) END,
CASE WHEN BI.AGGREGATE_BY = 'NONE' OR INSTR(BI.AGGREGATE_BY, 'MESSAGE_TYPE') !=
0 THEN A.MESSAGE_TYPE ELSE MAP(BI.MESSAGE_TYPE, '%', 'any',
BI.MESSAGE_TYPE) END,
BI.ORDER_BY
)
ORDER BY
MAP(ORDER_BY, 'TIME', EVENT_TIME) DESC,
MAP(ORDER_BY, 'COUNT', COUNT) DESC,
MAP(ORDER_BY, 'EVENT', EVENT_TYPE || EVENT_REASON)