Professional Documents
Culture Documents
HANA Threads ThreadSamples AggregationPerTimeSlice 2.00.040+
HANA Threads ThreadSamples AggregationPerTimeSlice 2.00.040+
/*
[NAME]
- HANA_Threads_ThreadSamples_AggregationPerTimeSlice_2.00.040+
[DESCRIPTION]
- Aggregation of thread samples on time slice basis (1 row with top areas per time
interval)
[SOURCE]
[VALID FOR]
[INVOLVED TABLES]
- M_SERVICE_THREAD_SAMPLES
- HOST_SERVICE_THREAD_SAMPLES
[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
Thread identifier
- THREAD_TYPE
- THREAD_STATE
- STATEMENT_HASH
- ROOT_STATEMENT_HASH
Root statement hash (e.g. hash of procedure responsible for statement execution)
- STATEMENT_THREAD_LIMIT
- STATEMENT_ID
- STATEMENT_EXECUTION_ID
- DB_USER
Database user
- APP_NAME
Name of application
- APP_USER
- APP_SOURCE
Application source
- LOCK_TYPE
'Basis System' --> Display samples with lock type 'Basis System'
'%' --> No restriction related to lock type
- LOCK_NAME
Lock name
- NUMA_NODE
Numa node
- CLIENT_IP
IP address of client
Client process ID
- CONN_ID
Connection ID
- PASSPORT_COMPONENT
Passport component
- PASSPORT_ACTION
Passport action
- JOB_QUEUEING
- MIN_SAMPLES_TOTAL
- TIME_SLICE_S
- ONLY_DELTA_STORAGE_WAITS
'X' --> Only display samples with methods linked to delta storage
waits
' ' --> No restriction related to delta storage waits
- EXCLUDE_SERVICE_THREAD_SAMPLER
'X' --> Samples related to service thread sampling are not shown
' ' --> All samples are displayed
- EXCLUDE_NEGATIVE_THREAD_IDS
- EXCLUDE_PHANTOM_THREADS
Possibility to exclude idle threads that are shown as "active" due to SAP HANA
bugs
'X' --> Do not show idle threads that are shown as active threads
' ' --> No restriction of displayed threads
- EXCLUDE_EMPTY_STATEMENT_IDS
- EXCLUDE_EMPTY_STATEMENT_EXECUTION_IDS
- DATA_SOURCE
- AGGREGATE_BY
- RESULT_ROWS
[OUTPUT PARAMETERS]
- SNAPSHOT_TIME: Begin time of considered time interval
- KEY_FIGURE: Key figure for which the top areas are determined
- SAMPLES_TOTAL: Total number of samples in considered time interval
- ACT_THREADS: Average number of total active threads
- DETAIL_<n>: Top <n> area
- SAMPLES_<n>: Number of thread samples for top <n> area
- PCT_<n>: Percentage of top <n> area compared to overall value
[EXAMPLE OUTPUT]
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------
|BEGIN_TIME |KEY_FIGURE |SAMPLES_TOTAL|ACT_THREADS|DETAIL_1|SAMPLES_1|
PCT_1|DETAIL_2 |SAMPLES_2|PCT_2|DETAIL_3 |SAMPLES_3|PCT_3|DETAIL_4
|SAMPLES_4|PCT_4|DETAIL_5 |SAMPLES_5|PCT_5|
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------
|2014/03/13 11:40:00|THREAD_STATE| 4451| 7.41|Running | 4422|
99|Job Exec Waiting| 18| 0|Network Read | 9| 0|Network Write
| 1| 0|Semaphore Wait | 1| 0|
|2014/03/13 11:30:00|THREAD_STATE| 4995| 8.32|Running | 4761|
95|Job Exec Waiting| 115| 2|Network Read | 84| 2|Sleeping
| 14| 0|Network Write | 9| 0|
|2014/03/13 11:20:00|THREAD_STATE| 4461| 7.43|Running | 4428|
99|Network Read | 18| 0|Job Exec Waiting| 14| 0|Network Write
| 1| 0| | | 0|
|2014/03/13 11:10:00|THREAD_STATE| 4407| 7.34|Running | 4399|
100|Network Read | 3| 0|Job Exec Waiting| 2| 0|Semaphore
Wait | 2| 0|Sleeping | 1| 0|
|2014/03/13 11:00:00|THREAD_STATE| 4533| 7.55|Running | 4499|
99|Job Exec Waiting| 24| 1|Network Read | 7| 0|Mutex Wait
| 3| 0| | | 0|
|2014/03/13 10:50:00|THREAD_STATE| 4544| 7.57|Running | 4503|
99|Job Exec Waiting| 29| 1|Network Read | 8| 0|Mutex Wait
| 4| 0| | | 0|
|2014/03/13 10:40:00|THREAD_STATE| 4476| 7.46|Running | 4447|
99|Job Exec Waiting| 12| 0|Network Read | 10| 0|Sleeping
| 2| 0|Semaphore Wait | 2| 0|
|2014/03/13 10:30:00|THREAD_STATE| 5061| 8.43|Running | 4831|
95|Job Exec Waiting| 108| 2|Network Read | 88| 2|Network Write
| 14| 0|Sleeping | 12| 0|
|2014/03/13 10:20:00|THREAD_STATE| 4474| 7.45|Running | 4444|
99|Network Read | 14| 0|Job Exec Waiting| 13| 0|Semaphore Wait
| 2| 0|Sleeping | 1| 0|
|2014/03/13 10:10:00|THREAD_STATE| 4410| 7.35|Running | 4393|
100|Network Read | 7| 0|Job Exec Waiting| 4| 0|Semaphore
Wait | 4| 0|Sleeping | 1| 0|
|2014/03/13 10:00:00|THREAD_STATE| 4475| 7.45|Running | 4444|
99|Job Exec Waiting| 21| 0|Network Read | 6| 0|Semaphore Wait
| 3| 0|Network Write | 1| 0|
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------
*/
SNAPSHOT_TIME,
KEY_FIGURE,
SAMPLES_TOTAL,
ACT_THREADS,
DETAIL_1,
SAMPLES_1,
PCT_1,
DETAIL_2,
SAMPLES_2,
PCT_2,
DETAIL_3,
SAMPLES_3,
PCT_3,
DETAIL_4,
SAMPLES_4,
PCT_4,
DETAIL_5,
SAMPLES_5,
PCT_5,
DETAIL_6,
SAMPLES_6,
PCT_6,
DETAIL_7,
SAMPLES_7,
PCT_7,
DETAIL_8,
SAMPLES_8,
PCT_8,
DETAIL_9,
SAMPLES_9,
PCT_9,
DETAIL10,
SAMPLES10,
PCT10
FROM
( SELECT
DISTINCT
BEGIN_TIME SNAPSHOT_TIME,
KEY_FIGURE,
SAMPLES_TOTAL,
ACT_THREADS,
IFNULL(TO_VARCHAR(MAX(DETAIL_1)), '') DETAIL_1,
IFNULL(LPAD(MAX(SAMPLES_1), 9), '') SAMPLES_1,
IFNULL(LPAD(MAX(PCT_1), 5), '') PCT_1,
IFNULL(TO_VARCHAR(MAX(DETAIL_2)), '') DETAIL_2,
IFNULL(LPAD(MAX(SAMPLES_2), 9), '') SAMPLES_2,
IFNULL(LPAD(MAX(PCT_2), 5), '') PCT_2,
IFNULL(TO_VARCHAR(MAX(DETAIL_3)), '') DETAIL_3,
IFNULL(LPAD(MAX(SAMPLES_3), 9), '') SAMPLES_3,
IFNULL(LPAD(MAX(PCT_3), 5), '') PCT_3,
IFNULL(TO_VARCHAR(MAX(DETAIL_4)), '') DETAIL_4,
IFNULL(LPAD(MAX(SAMPLES_4), 9), '') SAMPLES_4,
IFNULL(LPAD(MAX(PCT_4), 5), '') PCT_4,
IFNULL(TO_VARCHAR(MAX(DETAIL_5)), '') DETAIL_5,
IFNULL(LPAD(MAX(SAMPLES_5), 9), '') SAMPLES_5,
IFNULL(LPAD(MAX(PCT_5), 5), '') PCT_5,
IFNULL(TO_VARCHAR(MAX(DETAIL_6)), '') DETAIL_6,
IFNULL(LPAD(MAX(SAMPLES_6), 9), '') SAMPLES_6,
IFNULL(LPAD(MAX(PCT_6), 5), '') PCT_6,
IFNULL(TO_VARCHAR(MAX(DETAIL_7)), '') DETAIL_7,
IFNULL(LPAD(MAX(SAMPLES_7), 9), '') SAMPLES_7,
IFNULL(LPAD(MAX(PCT_7), 5), '') PCT_7,
IFNULL(TO_VARCHAR(MAX(DETAIL_8)), '') DETAIL_8,
IFNULL(LPAD(MAX(SAMPLES_8), 9), '') SAMPLES_8,
IFNULL(LPAD(MAX(PCT_8), 5), '') PCT_8,
IFNULL(TO_VARCHAR(MAX(DETAIL_9)), '') DETAIL_9,
IFNULL(LPAD(MAX(SAMPLES_9), 9), '') SAMPLES_9,
IFNULL(LPAD(MAX(PCT_9), 5), '') PCT_9,
IFNULL(TO_VARCHAR(MAX(DETAIL_10)), '') DETAIL10,
IFNULL(LPAD(MAX(SAMPLES_10), 9), '') SAMPLES10,
IFNULL(LPAD(MAX(PCT_10), 5), '') PCT10,
ROW_NUMBER () OVER (ORDER BY BEGIN_TIME DESC) ROWNO,
RESULT_ROWS,
MIN_SAMPLES_TOTAL
FROM
( SELECT DISTINCT
TO_VARCHAR(BEGIN_TIME, 'YYYY/MM/DD HH24:MI:SS') BEGIN_TIME,
AGGREGATE_BY KEY_FIGURE,
LPAD(SUM(NUM_SAMPLES) OVER (PARTITION BY BEGIN_TIME), 13) SAMPLES_TOTAL,
LPAD(TO_DECIMAL(SUM(ACT_THREADS) OVER (PARTITION BY BEGIN_TIME), 10, 2), 11)
ACT_THREADS,
NTH_VALUE(VALUE, 1) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES DESC)
DETAIL_1,
NTH_VALUE(NUM_SAMPLES, 1) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES
DESC) SAMPLES_1,
TO_DECIMAL(ROUND(NTH_VALUE(PERCENT, 1) OVER (PARTITION BY BEGIN_TIME ORDER BY
NUM_SAMPLES DESC)), 10, 0) PCT_1,
NTH_VALUE(VALUE, 2) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES DESC)
DETAIL_2,
NTH_VALUE(NUM_SAMPLES, 2) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES
DESC) SAMPLES_2,
TO_DECIMAL(ROUND(NTH_VALUE(PERCENT, 2) OVER (PARTITION BY BEGIN_TIME ORDER BY
NUM_SAMPLES DESC)), 10, 0) PCT_2,
NTH_VALUE(VALUE, 3) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES DESC)
DETAIL_3,
NTH_VALUE(NUM_SAMPLES, 3) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES
DESC) SAMPLES_3,
TO_DECIMAL(ROUND(NTH_VALUE(PERCENT, 3) OVER (PARTITION BY BEGIN_TIME ORDER BY
NUM_SAMPLES DESC)), 10, 0) PCT_3,
NTH_VALUE(VALUE, 4) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES DESC)
DETAIL_4,
NTH_VALUE(NUM_SAMPLES, 4) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES
DESC) SAMPLES_4,
TO_DECIMAL(ROUND(NTH_VALUE(PERCENT, 4) OVER (PARTITION BY BEGIN_TIME ORDER BY
NUM_SAMPLES DESC)), 10, 0) PCT_4,
NTH_VALUE(VALUE, 5) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES DESC)
DETAIL_5,
NTH_VALUE(NUM_SAMPLES, 5) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES
DESC) SAMPLES_5,
TO_DECIMAL(ROUND(NTH_VALUE(PERCENT, 5) OVER (PARTITION BY BEGIN_TIME ORDER BY
NUM_SAMPLES DESC)), 10, 0) PCT_5,
NTH_VALUE(VALUE, 6) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES DESC)
DETAIL_6,
NTH_VALUE(NUM_SAMPLES, 6) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES
DESC) SAMPLES_6,
TO_DECIMAL(ROUND(NTH_VALUE(PERCENT, 6) OVER (PARTITION BY BEGIN_TIME ORDER BY
NUM_SAMPLES DESC)), 10, 0) PCT_6,
NTH_VALUE(VALUE, 7) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES DESC)
DETAIL_7,
NTH_VALUE(NUM_SAMPLES, 7) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES
DESC) SAMPLES_7,
TO_DECIMAL(ROUND(NTH_VALUE(PERCENT, 7) OVER (PARTITION BY BEGIN_TIME ORDER BY
NUM_SAMPLES DESC)), 10, 0) PCT_7,
NTH_VALUE(VALUE, 8) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES DESC)
DETAIL_8,
NTH_VALUE(NUM_SAMPLES, 8) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES
DESC) SAMPLES_8,
TO_DECIMAL(ROUND(NTH_VALUE(PERCENT, 8) OVER (PARTITION BY BEGIN_TIME ORDER BY
NUM_SAMPLES DESC)), 10, 0) PCT_8,
NTH_VALUE(VALUE, 9) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES DESC)
DETAIL_9,
NTH_VALUE(NUM_SAMPLES, 9) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES
DESC) SAMPLES_9,
TO_DECIMAL(ROUND(NTH_VALUE(PERCENT, 9) OVER (PARTITION BY BEGIN_TIME ORDER BY
NUM_SAMPLES DESC)), 10, 0) PCT_9,
NTH_VALUE(VALUE, 10) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES DESC)
DETAIL_10,
NTH_VALUE(NUM_SAMPLES, 10) OVER (PARTITION BY BEGIN_TIME ORDER BY NUM_SAMPLES
DESC) SAMPLES_10,
TO_DECIMAL(ROUND(NTH_VALUE(PERCENT, 10) OVER (PARTITION BY BEGIN_TIME ORDER
BY NUM_SAMPLES DESC)), 10, 0) PCT_10,
RESULT_ROWS,
MIN_SAMPLES_TOTAL
FROM
( SELECT
BEGIN_TIME,
AGGREGATE_BY,
RESULT_ROWS,
VALUE,
COUNT(*) NUM_SAMPLES,
COUNT(*) / SUM(COUNT(*)) OVER (PARTITION BY BEGIN_TIME) * 100 PERCENT,
COUNT(*) * LEAST(SAMPLE_INTERVAL, TIME_SLICE_S) / TIME_SLICE_S
ACT_THREADS,
MIN_SAMPLES_TOTAL
FROM
( SELECT
ADD_SECONDS(TO_TIMESTAMP('2014/01/01 00:00:00', 'YYYY/MM/DD HH24:MI:SS'),