A work class is a method of categorizing individual database
activities based on attributes of the activities. Work classes are
grouped into work class sets, which can be shared by different work
action sets.
Examples of database activity attributes
which can determine which work class an activity is associated with
includes: activity type (DDL, DML, LOAD), the estimated cost (where
available), the estimated cardinality (where available), the estimated
data tag, and the schema (where available).
Work classes
A work class has the following
attributes:
- The work class name, which must be unique in the work class set.
- The database activity attributes, which consist of the following
information:
- The type of database activity that falls into this work class.
Using predefined keywords (for example, CALL, READ, WRITE, DML, DDL,
LOAD, or ALL), you can classify database requests into different categories.
Different types of database activities can be associated with a work
class depending on its work type. For example, the WRITE keyword includes
updates, deletes, inserts, merges, and selects that contain a delete,
insert, or update. For more information, see Work identification by type, cost, or data accessed with work classes.
- The range information that further categorizes DML or XQuery types
of database activity:
- The type of range to specify (either timeron cost or cardinality).
Specifying a range of values is optional. For example, when you specify
a range for a work class, you can specify that all queries with an
estimated cost of less than 100 timerons be processed differently
than other queries.
- The bottom of the range.
- The top of the range.
- The schema of the routine to be called. Specifying the schema
is optional. When defining a work class, you can use the schema attribute
to further classify CALL statements according to the schema of the
procedure being called. For example, if you specify SCHEMA1 for the
schema of a work class and the work type is CALL, all CALL statements
calling a SCHEMA1 procedure are classified in that work class. If
you specify the schema for a work class type other than CALL or ALL,
the error SQL0628N is returned.
- The identification tag given to the
data the activity might touch. For example, when you specify a data
tag of 3 for a work class, activities that touch data in a table space
or storage group with a data tag of 3 can be isolated and treated
differently.
- The evaluation order of the work class (or position of the work
class in the work class set). For more information, see Evaluation order of work classes in a work class set.
- An automatically generated class identifier that uniquely identifies
the work class.
You can create work classes in two ways:
- Create a new work class set to contain the new work class using
the WORK CLASS keyword of the CREATE WORK CLASS SET statement.
- Add the new work class to an existing work class set using the
ADD keyword of the ALTER WORK CLASS SET statement
You can alter work classes by using the ALTER WORK CLASS
keyword of the ALTER WORK CLASS SET statement.
You can drop
work classes from a work class set using the DROP WORK CLASS keyword
of the ALTER WORK CLASS SET statement, or by using the DROP WORK CLASS
SET statement to drop the work class set.
You can view your
work classes by querying the SYSCAT.WORKCLASSES view.
Work class sets
You use work class sets
to group one or more work classes. A work class set consists of the
following attributes:
- A unique descriptive name for the work class set
- Any comments that you want to supply for the work class set
- Zero or more work classes (although a work class can only exist
in a work class set, a work class set does not have to contain any
work classes)
- An automatically generated ID that uniquely identifies the work
class set
You create a new work class set using the CREATE WORK
CLASS SET statement. You can create an empty work class set and add
work classes later, or you can create a work class set that contains
one or more work classes.
You change an existing work class
set in the following ways using the ALTER WORK CLASS SET statement:
- Add work classes to the work class set.
- Change work class attributes for work classes in the work class
set.
- Drop work classes from the work class set.
You cannot change any work class set attributes.
Drop
a work class set using the DROP WORK CLASS SET statement.
You
can view your work class sets by querying the SYSCAT.WORKCLASSSETS
catalog view.
The following figure shows an example of work
classes in a work class set.
Figure 1. Example
of work classes and a work class set
For a work class set to be effective
on the system, you must define a work action set and associate it
with the work class set. By using a work action set, you can associate
a work class set to a service superclass, a workload, or a database,
to indicate what action should be applied to the database activities
that fall within the classification. If you do not create a work action
set for the work class set, the data server ignores the work class
set.