Sorry, but I had to upload it here as a file, I don't know if it's due to the length but I am not able to paste it, if I do it I receive an error.
Original Message:
Sent: 08/27/26 03:09 PM
From: Soledad Martinez
Subject: Deletes on the SYSIBM.SYSOBJEVENTS, when? Why?
Hello Craig
thank you very much for sharing!! I was following a similar approach based of the COUNT of the mapping table, but I had an error on my solution, and thanks to you I was able to fix it!
It is not as powerful as yours, as I am not storing the data, just wanted to identify the REORG DISCARD. I am pasting it below.
Now for identifying the mapping index I assume that it will never be in the same database that the tablespace to be reorged as not always there is a dedicated database for it for the whole system.
It's a pity we cannot meet at IDUG, but we can keep in touch, I can share with you what I have in mind. My idea is to present something practical or useful, that's why I was playing on how to identify this or other things via the history tables.
Thank you very much you really made my day! :-)
------------------------------
Soledad Martinez
Db2 z/OS System Programmer
Volkswagen Group Services
Salinas - Asturias
------------------------------
Original Message:
Sent: 08/27/26 07:04 AM
From: CRAIG MCKELLAR
Subject: Deletes on the SYSIBM.SYSOBJEVENTS, when? Why?
Hi Soledad
While I won't be able to attend IDUG, I would be interested in what you present on this topic.
This is my SQL that I use to extract the discarded rows and then insert the results into a table holding the table name, job name, time and discarded rows. With regards to partition discards it still appears to work, I sum the Type=T (tablespaces) counts and subtract that from the mapping table (type=I) rows unloaded. There are some events where there small number discrepancies and do not have a DISCARD in the reorg which I can't explain but choose to ignore.
This SQL is also built so it can be rerun and pick up from where the last run finished hence setting the global variable at the beginning. See what you think.
Ultimately I would like the AHA to be accepted and have DISCARD count included but this will work for now.
I would also put a plug here for another AHA I have just raised but relevant to this thread.
https://ibm-data-and-ai.ideas.ibm.com/ideas/DB24ZOS-I-1926 Enable Compression for Selected DSNDB06 Tables This one is to be able to use compression on the utility and RTS history tables.
and the DISCARD
https://ibm-data-and-ai.ideas.ibm.com/ideas/DB2UTILSTZ-I-106 Add DISCARD row count from Reorg to Utility history SYSOBJEVENTS table
The SQL:
-- ============================================================
-- REORG DISCARD COUNT: TYPE='I' (DBARMAP%) MINUS TYPE='T'
-- USES: SYSIBM.SYSOBJEVENTS
-- SYSIBM.SYSUTILITIES (JOINED ON EVENTID FOR JOBNAME, UTILID)
--
-- FOR EACH EVENTID THAT HAS A TYPE='I' ROW WITH DBNAME LIKE 'DBARMAP%'
-- WITHIN THE LAST 7 DAYS, JOINS TO THE CORRESPONDING TYPE='T' ROW AND
-- TO SYSUTILITIES TO ENRICH THE RESULT WITH JOBNAME AND UTILID.
--
-- DISCARD = COUNT(OBJTYPE='I', DBARMAP%) â?? COUNT(OBJTYPE='T')
--
-- A POSITIVE DISCARD VALUE REPRESENTS ROWS COUNTED IN THE INDEX PHASE
-- THAT WERE NOT PRESENT AT TERMINATION (I.E. DISCARDED BY THE REORG).
--
-- ?TOPIC=TABLES-SYSOBJEVENTS
--- ?TOPIC=TABLES-SYSUTILITIES
-- ============================================================
-- SET GV TO LAST INSERTED ROW FOR DISCARDRG
-- THIS ALLOWS CONTINUOUS RUNNING OF THIS QUERY
SET
DBA.LASTEVENT_TS =
COALESCE((SELECT DISTINCT(MAX(EVENT_TS ))
FROM DBA.DISCARDRG), CURRENT TIMESTAMP - 7 DAYS);
SELECT DBA.LASTEVENT_TS FROM SYSIBM.SYSDUMMY1;
--
INSERT INTO "DBA"."DISCARDRG"
(EVENTID,TBNAME,DBNAME_T,OBJNAME_T,
EVENT_TS,JOBNAME,
UTILID,ROWS_UNLOADED,ROW_RELOADED,
DISCARD)
WITH
-- OBJTYPE='I' ROWS ANCHORED TO THE DBARMAP% DATABASE PATTERN
-- WITHIN THE LAST 7 DAYS.
EVT_I AS (
SELECT
EVENTID,
DBNAME AS DBNAME_I,
SPACENAME,
COUNT AS COUNT_I,
EVENTTS AS EVENT_TS
FROM
SYSIBM.SYSOBJEVENTS
WHERE
OBJTYPE = 'I'
AND DBNAME LIKE 'DBARMAP%'
AND EVENTID IN (
SELECT EVENTID FROM
SYSIBM.SYSUTILITIES
WHERE
NAME='REORG'
AND EVENTID NOT IN
( SELECT EVENTID FROM
DBA.DISCARDRG )
AND ENDTS > DBA.LASTEVENT_TS)
),
-- OBJTYPE='T' (TERMINATION) ROWS FOR EVERY EVENTID FOUND ABOVE.
-- NO DBNAME FILTER THE TERMINATION ROW MAY CARRY A DIFFERENT DBNAME.
EVT_T AS (
SELECT
-- NAME,
EVENTID,
DBNAME AS DBNAME_T,
SPACENAME AS OBJNAME_T,
SUM(COUNT) AS COUNT_T,
EVENTTS AS TS_T
FROM
SYSIBM.SYSOBJEVENTS
WHERE
OBJTYPE = 'T'
AND EVENTID IN (
SELECT EVENTID FROM
SYSIBM.SYSUTILITIES
WHERE
NAME='REORG'
AND EVENTID NOT IN
( SELECT EVENTID FROM
DBA.DISCARDRG )
AND ENDTS > DBA.LASTEVENT_TS)
GROUP BY EVENTID,DBNAME,SPACENAME,EVENTTS
),
-- SYSUTILITIES: ONE CONTROL ROW PER UTILITY INSTANCE (1=1).
-- PROVIDES JOBNAME AND UTILID KEYED ON EVENTID.
UTILS AS (
SELECT
EVENTID,
UTILID,
JOBNAME
FROM
SYSIBM.SYSUTILITIES
WHERE
1 = 1 -- TOP-LEVEL CONTROL ROW ONLY
),
-- SYSTABLES: LOOK UP TABLE NAME BY DATABASE + TABLESPACE NAME.
TBLS AS (
SELECT
DBNAME,
TSNAME,
NAME AS TBNAME
FROM
SYSIBM.SYSTABLES
WHERE TYPE='T'
)
SELECT
I.EVENTID,
TB.TBNAME,
T.DBNAME_T,
T.OBJNAME_T,
I.EVENT_TS,
U.JOBNAME,
U.UTILID,
I.COUNT_I AS ROWS_UNLOADED,
T.COUNT_T AS ROWS_RELOADED,
I.COUNT_I - T.COUNT_T AS DISCARD
FROM
EVT_I I
INNER JOIN
EVT_T T
ON T.EVENTID = I.EVENTID
INNER JOIN
UTILS U
ON U.EVENTID = I.EVENTID
LEFT JOIN
TBLS TB
ON TB.DBNAME = T.DBNAME_T
AND TB.TSNAME = T.OBJNAME_T
WHERE
I.COUNT_I - T.COUNT_T > 0
ORDER BY
I.EVENT_TS,
U.JOBNAME,
I.EVENTID,
T.OBJNAME_T;
------------------------------
CRAIG MCKELLAR
------------------------------
Original Message:
Sent: 08/26/26 08:41 AM
From: Soledad Martinez
Subject: Deletes on the SYSIBM.SYSOBJEVENTS, when? Why?
Hello Craig,
oh, yes please, it would be great if you could share the way you have to identify them. I agree with you that it will be very helpful for audit trail.
I tried to catch the REORG DISCARDS just with a query, started with the DSN8D13* tables, then move to bigger tables and also worked as expected. But ... when I tested it in a real environment with REORGS by PARTITION ... all gone down the drain :-)
I had seen your idea at the AHA before and thought it was a must. You already had my vote days ago!!!
I opened one for the DSNUTIL unloads, I think it should be great to have them also at these tables.
Thank you very much!!
------------------------------
Soledad Martinez
Db2 z/OS System Programmer
Volkswagen Group Services
Salinas - Asturias
------------------------------
Original Message:
Sent: 08/26/26 08:08 AM
From: CRAIG MCKELLAR
Subject: Deletes on the SYSIBM.SYSOBJEVENTS, when? Why?
Hi Soledad. Just an update to capturing discard from objevents. I have written SQL that will capture the discarded row counts and insert into a table containing the counts, table name and job name for each reorg. It seems to work well on all reorg levels. Happy to share it. From this though I have raised an AHA to have the discarded row count added to the objevents table. This can be done from the message in the reorg job. This aha does have some interest from the labs.
------------------------------
CRAIG MCKELLAR
------------------------------
Original Message:
Sent: 08/25/26 10:20 AM
From: Soledad Martinez
Subject: Deletes on the SYSIBM.SYSOBJEVENTS, when? Why?
Hello Michael,
I did several testing with reorg discard, because I am tring to identify them from the SYSOBJEVENTS, but there are too many casuistics thatn I started to think that is not possible. I am preparing a session for IDUG and I thought this could be cool.
For example, this below are the counters from a REORG DISCARD. It's easy to identify that one row was discarded because the count for IM5D33FD (mapping-index) is bigger than the counter of the indexes and also bigger than the sum of the count rows of the 5 partitions:

But this doesn't work when the REORG DISCARD was done at Partition Level, because in that case the mapping table and the NPSI counter is always bigger that the sum of the count of the partition being reorged.
Anyway, as REORG DISCARD is updating the REORG* counters at the RTS table, I assume that it will always be reset to 0 just after the REORG DISCARD be done. Don't you think so?
Thanks!
------------------------------
Soledad Martinez
Db2 z/OS System Programmer
Volkswagen Group Services
Salinas - Asturias
------------------------------
Original Message:
Sent: 08/24/26 05:13 AM
From: Michael Lowe
Subject: Deletes on the SYSIBM.SYSOBJEVENTS, when? Why?
Hi Soledad
Does the REORG statement contain a DISCARD keyword?
Regards
Michael Lowe
Db2 z/OS Instructor, Manchester UK
------------------------------
Michael Lowe
------------------------------