The DB2 Universal Database™ for iSeries™ Predictive Query Governor can stop the initiation of a query if the estimated run time (elapsed execution time) or estimated temporary storage for the query is excessive. The governor acts before a query is run instead of while a query is run. The governor can be used in any interactive or batch job on the iSeries. It can be used with all DB2 Universal Database for iSeries query interfaces and is not limited to use with SQL queries.
The governor in DB2 Universal Database for iSeries is based on two measurements:
If the query’s estimated runtime or temporary storage usage exceed the user defined limits, the initiation of the query can be stopped.
To define a time limit (in seconds) for the governor to use, do one of the following:
To define a temporary storage limit (in megabytes) for the governor to use, do the following:
It is important to remember that the time and temporary storage values generated by the optimizer are only estimates. The actual query runtime might be more or less than the estimate. In certain cases when the optimizer does not have full information about the data being queried, the estimate may vary considerably from the actual resource used. In those case, you may need to artificially adjust your limits to correspond to an inaccurate estimate.
When setting the time limit for the entire server, it is typically best to set the limit to the maximum allowable time that any query should be allowed to run. By setting the limit too low you will run the risk of preventing some queries from completing and thus preventing the application from successfully finishing. There are many functions that use the query component to internally perform query requests. These requests will also be compared to the user-defined time limit.
You can check the inquiry message CPA4259 for the predicted runtime and storage. If the query is canceled, debug messages will still be written to the job log.
You can also add the Query Governor Exit Program that is called when estimated runtime and temporary storage limits have exceeded the specified limits.