You are on page 1of 10

Purging Workflow tables

Master workflow runtime table is WF_ITEMS. All other runtime table records
are associated to record in WF_ITEMS. If records are purged in WF_ITEMS,
records are purged in all other workflow runtime tables.

Below query will help you to determine volume of wf process classified by


Status, item Type, and permanency.

select wi.item_type ITEM_TYPE, wit.persistence_type P_TYPE, decode


(wi.end_date, NULL, 'OPEN', 'CLOSED') Status, count(*) COUNT

from wf_items wi, wf_item_types wit

where wit.name = wi.item_type

group by item_type, wit.persistence_type, WIT.PERSISTENCE_DAYS, decode


(wi.end_date, NULL, 'OPEN', 'CLOSED')

order by decode (wi.end_date, NULL, 'OPEN', 'CLOSED'), 4 desc;

These below queries give the volume of data in the tables.

select count(*) from WF_ITEM_ATTRIBUTE_VALUES;

select count(*) from WF_ITEM_ACTIVITY_STATUSES;

select count(*) from WF_NOTIFICATION_ATTRIBUTES;


The SQL statements below will help analyze their contents

The main tables of concern when dealing with workflows are


WF_ITEM_ACTIVITY_STATUS and WF_ITEM_ATTRIBUTE_VALUES..

select item_type,activity_status,count(*)

from wf_item_activity_statuses

group by item_type,activity_status

Output :

ITEM_TYP ACTIVITY COUNT(*)

-------- -------- ----------

INVTROAP COMPLETE 8

WFERROR COMPLETE 413298

INVTROAP DEFERRED 1

CREATEPO ERROR 5

An understanding of WFERROR will help define what needs to happen next:

ACTIVE Nobody has reviewed these yet COMPLETE Someone has


responded to the error notification with abort/retry/ignore. These are
complete and should be purged.
ERROR The error process is in error. This usually happens on new sites
where the configuration is incomplete. For example, an error process
notification was sent to non-existent person. Reviewing the error stack should
tell you what the problem is.

NOTIFIED A workflow exception has been raised and the wferror process
started. There will be an unactioned notification somewhere on the system.

APIs provided for purging

WF_PURGE is the database defined package which contains the APIs to purge
workflow runtime tables.

The history information for workflows marked as Permanent can only be


removed by WF_PURGE.TOTALPERM; the history information for workflows
marked as Temporary is removed by WF_PURGE.TOTAL. For best
performance, run WF_PURGE.TOTAL frequently, and WF_PURGE.TOTALPERM
periodically, but be aware of your sites policy on status history retention

The most commonly used procedures are:

Procedure Parameters Description

WF_PURGE.ITEMS Itemtype

Itemkey

Enddate Removes all run-time data associated with completed items.

WF_PURGE.ACTIVITIES Itemtype
Enddate Removes obsolete activities versions. These are versions of
activities that are no longer used by any item.

WF_PURGE.NOTIFICATIONS Itemtype

Enddate Removes old notifications. These are notifications that are no


longer used by any item.

WF_PURGE.TOTAL Itemtype

Itemkey

Enddate Purges both item and activity data.

WF_PURGE.TOTALPERM Itemtype

Itemkey

Enddate Deletes all eligible obsolete run-time data that has a persistence
type of Permanent.

WF_PURGE.ADHOCDIRECTORY Enddate Purges all ad hoc users and


roles that are not associated with a notification.

Wf_Purge.Items:

Purge all runtime date associated with completed items, their processes, and
notifications sent by them.

Deletes from the tables: WF_NOTIFICATIONS, WF_ITEM_ACTIVITY_STATUSES,

WF_ITEM_ATTRIBUTE_VALUES AND WF_ITEMS/

Parameters:

itemtype : Item type to delete, or null for all itemtypes


itemkey : Item key to delete, or null for all itemkeys

enddate : Purges wf processes closed after this date

force : Forces to purge closed wf processes even if it has wf slibing

processes open.

docommit : TRUE does commit, FALSE deleted but does not commit.

Wf_Purge.Activities :

Purges wf process definition versions that are not used and that are obsolete.

Deletes from tables:

WF_ACTIVITY_ATTR_VALUES,

WF_ACTIVITY_TRANSITIONS,

WF_PROCESS_ACTIVITIES,

WF_ACTIVITY_ATTRIBUTES_TL,

WF_ACTIVITY_ATTRIBUTES,

WF_ACTIVITIES_TL and

WF_ACTIVITIES that are associated with the specified item type,

have an END_DATE less than or equal to the specified end date and

are not referenced by an existing item as either a process or activity.

Wf_Purge.Total : Purge both item data and activity data.

Wf_Purge.AdHocDirectory :

Purge users and roles in the WF_LOCAL_* tables

whose expiration date has elapsed and that are not referenced in any
notification.

Open notifications Finding


Use the following query to find count of how many open notifications are
present which were to be delivered to sysadmin and of message type
WFERROR which are older than x number of days

SELECT count(*) FROM wf_notifications WHERE MESSAGE_TYPE =


'WFERROR' AND status = 'OPEN' AND original_recipient = 'SYSADMIN' AND
begin_date < SYSDATE - X;

Once you decide upon the number of days. Then you will have to run the
following script by login with apps user.

This SQL find the open notifications who had recipient as sysadmin and
whose begin date is older than x days.

*****

SELECT SYSDATE start_dt

FROM DUAL;

DECLARE

l_commit_count NUMBER := 1;

l_commit_interval NUMBER := 5000;

CURSOR c1

IS

SELECT notification_id
FROM wf_notifications

WHERE MESSAGE_TYPE = 'WFERROR'

AND status = 'OPEN'

AND original_recipient = 'SYSADMIN'

AND begin_date < SYSDATE - X;

BEGIN

FOR c1rec IN c1

LOOP

wf_notification.respond (nid => c1rec.notification_id);

IF l_commit_count = l_commit_interval

THEN

COMMIT;
l_commit_count := 1;

ELSE

l_commit_count := l_commit_count + 1;

END IF;

END LOOP;

EXCEPTION

WHEN OTHERS

THEN

ROLLBACK;

RAISE;

END;

SELECT SYSDATE end_dt


FROM DUAL;

*****

Run the PURGE WORKFLOW

Use the standard concurrent program FNDWFPR Purge Obsolete Workflow


Runtime Data to purge old data from the Oracle Workflow runtime tables
regularly.

You can supply the following parameters for thePurge Obsolete Workflow
Runtime

Data concurrent program:

Item Type the item type to purge. Leaving this field blank Defaults to
purging the runtime data for all item types

Item Key The item key to purge. Leaving this fie defaults to purging the
runtime data for all item keys.

Age Minimum age of data to purge, in days.

Gather Stats

Once it is done please GATHER STATS for the fall tables owned by apps user
WF_ITEM_ACTIVITY_STATUSES

WF_ITEM_ACTIVITY_STATUSES_H

WF_NOTIFICATION_ATTRIBUTES

WF_COMMENTS

WF_NOTIFICATIONS

WF_ITEM_ATTRIBUTE_VALUES

WF_ITEMS

WF_ACTIVITY_ATTR_VALUES

WF_ACTIVITY_TRANSITIONS

WF_PROCESS_ACTIVITIES

WF_ACTIVITY_ATTRIBUTES_TL

WF_ACTIVITIES_TL

WF_ACTIVITIES

WF_LOCAL_USER_ROLES

WF_USER_ROLE_ASSIGNMENTS

WF_LOCAL_ROLES

Eg: EXECUTE dbms_stats.gather_table_stats (ownname=>APPLSYS,


tabname=><Above table Name>,estimate_percent=>10);

You might also like