Control long-running queries with the DB2 UDB for AS/400 Predictive Query Governor

The DB2 UDB for AS/400 Predictive Query Governor can stop the initiation of a query if the estimated or predicted run time (elapsed execution time) 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 AS/400. It can be used with all DB2 UDB for AS/400 query interfaces and is not limited to use with SQL queries.

The ability of the governor to predict and stop queries before they are started is important because:

The governor in DB2 UDB for AS/400 is based on the estimated runtime for a query. If the query's estimated runtime exceeds the user defined time limit, the initiation of the query can be stopped.

To define a time limit for the governor to use, do one of the following:

How the query governor works

The governor works in conjunction with the query optimizer. When a user requests DB2 UDB for AS/400 to run a query, the following occurs:

  1. The query access plan is evaluated by the optimizer.

    As part of the evaluation, the optimizer predicts or estimates the runtime for the query. This helps determine the best way to access and retrieve the data for the query.

  2. The estimated runtime is compared against the user-defined query time limit currently in effect for the job or user session.
  3. If the predicted runtime for the query is less than or equal to the query time limit, the query governor lets the query run without interruption and no message is sent to the user.
  4. If the query time limit is exceeded, inquiry message CPA4259 is sent to the user. The message states that the estimated query processing time of XX seconds exceeds the time limit of YY seconds.
    Note:A default reply can be established for this message so that the user does not have the option to reply to the message, and the query request is always ended.
  5. If a default message reply is not used, the user chooses to do one of the following:


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]