AUTO_READAHEAD session environment option
Use the AUTO_READAHEAD environment option to change the automatic read-ahead mode or the page-count, or to disable automatic read-ahead operations for the current session.
The AUTO_READAHEAD session environment option has this syntax:
Element | Description | Restrictions | Syntax |
---|---|---|---|
pages | Number of data pages to read ahead | Must be an integer in the range '4' < 'page' < '4096' |
Quoted String |
Usage
- A required mode setting, encoded as a digit in the range
0
< mode <2
- An optional pages setting, encoded as an integer in the
range
4
< page <4096
.
Setting the mode to aggressive, standard, or disabled
You can change the automatic read-ahead mode for the current session by specifying one of the following values as the first AUTO_READAHEAD parameter:
- '0' or "0"
- Disable automatic read-ahead requests.
- '1' or "1"
- Enable automatic read-ahead requests in the standard mode. The server will automatically process read-ahead requests only when a query waits on I/O.
- '2' or "2"
- Enable automatic read-ahead requests in the aggressive mode. The server will automatically process read-ahead requests at the start of the query, and continuously through the duration of the query.
The value that you specify for the mode overrides the setting of the AUTO_READAHEAD configuration parameter for the session.
- The SET ENVIRONMENT AUTO_READAHEAD statement (for a session)
- The AUTO_READAHEAD configuration parameter value of 1 or 2.
- If AUTO_READAHEAD has no setting in the onconfig file, but the AUTO_TUNE configuration parameter is set to 1, the server performs automatic read-ahead on 128 data pages, equivalent to the default pages value in the standard mode.
Setting the number of pages to read ahead
- 'pages' or "pages"
- Specifies the number of data pages (as an integer in the range
4
< 'pages' <4096
) read by the database server when it receives an automatic read-ahead request.
The specified "pages" value overrides the explicit or default page-count setting of the AUTO_READAHEAD configuration parameter for the current session.
If the SET ENVIRONMENT AUTO_READAHEAD statement includes no second parameter, the page-count value defaults to the explicit AUTO_READAHEAD configuration parameter setting, or to 128 pages, if that configuration parameter is not set.
Examples of setting AUTO_READAHEAD
SET ENVIRONMENT AUTO_READAHEAD '0';
SET ENVIRONMENT AUTO_READAHEAD '1';
SET ENVIRONMENT AUTO_READAHEAD '1','1924';
Generally, the standard mode (AUTO_READAHEAD = 1) is appropriate in typical production environments, even for cached environments, but the SET ENVIRONMENT AUTO_READAHEAD statement enables you to take action in contexts where the efficiency of specific scans might benefit from modifying the read-ahead behavior.
SET ENVIRONMENT AUTO_READAHEAD '2';
Use
aggressive read-ahead operations only in situations in which you tested
both settings and know that aggressive read-ahead operations are more
effective. Do not use aggressive read-ahead operations if you are
not sure that they are more effective. For scans that might turn read-ahead operations off and on because the scan encounters pockets of cached data, aggressive mode read-ahead operations do not turn off read-ahead operations.