IBM Support

IBM .Net provider and "Estimated Query timeout limit exceeded"

Troubleshooting


Problem

The IBM.Data.DB2.iSeries .NET data provider supports the "CommandTimeout" property used to specify the maximum time an SQL statement should run.

Resolving The Problem

The IBM.Data.DB2.iSeries .Net database provider includes the iDB2Command Class Property "CommandTimeout" that can be used to specify the allowed time for SQL statements to run. The default value for this property is 30 seconds. When SQL statements are run, the database will run the statement only if the estimated run time is less than the value of the "CommandTimeout" property. If this happens, the application will receive the following message: SQL0666 - Estimated query processing time X exceeds limit Y.

Despite the wording of this method in the 'DB2 for i .NET Provider' technical reference, this message is issued before the statement is run. It makes use of the predictive query governor in DB2 on i rather than simply stopping the query after a preset number of seconds. Therefore, if the estimate is lower than the specified value but the statement runs longer, it will not stop processing after the command timeout has expired. To resolve SQL0666 error messages, change the "CommandTimeout" parameter to exceed the value in the SQL0666 error message. Alternatively, a value of 0 may specified to indicate that no timeout should be imposed.

Note that if the command.Prepare method is called, the CommandTimeout must be set BEFORE calling Prepare or it will have no effect. Calling Prepare causes the flow to the host that sets the query timeout value as well as the command text which is prepared.

CommandTimeout property examples

Visual Basic Example
Public Sub Example()

Dim cn As New iDB2Connection("DataSource=myiSeries;")
Dim cmd As New iDB2Command()
cmd.CommandText = "select * from mylib.mytable"
cmd.CommandType = CommandType.Text
cmd.CommandTimeout = 0
End Sub


C# Example
public void Example()
{
iDB2Connection cn = new iDB2Connection("DataSource=myiSeries;");
iDB2Command cmd = new iDB2Command();
cmd.CommandText = "select * from mylib.mytable";
cmd.CommandType = CommandType.Text;
cmd.CommandTimeout = 0;

}

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"6.1.0"}]

Historical Number

396580011

Document Information

More support for:
IBM i

Software version:
6.1.0

Operating system(s):
IBM i

Document number:
637925

Modified date:
18 December 2019

UID

nas8N1015237

Manage My Notification Subscriptions