I have a problem with a script timing out while fetching data form a query on large table.
The table have 9,521,457 rows.
The query I\'m trying to preform is
command.CommandTimeout = int.MaxValue;
If you know more exactly which number to insert, do that. If you set it to int.MaxValue
, you are removing a security barrier.
command.CommandTimeout = 2147483;
The largest value for a MySQL command timeout is the largest value for a 32 bit integer, in milliseconds, 2147483647. But in C# the CommandTimeout property is in seconds, not milliseconds, so any higher than 2147483 will result in an exception.
Although this is not infinite, it is 24 days, 20 hours, 31 minutes, and 23 seconds, which would hopefully meet your need.
Setting the value to 0 did not work for me. The CommandTimeout property would not retain the value of 0 and kept auto-changing back to 30.
Setting the value to -1 did seem to work, but I didn't test it enough to be certain that a timeout would never occur.
Safest option: go with 2147483.
Add an index on the customerId
column.
Set the CommandTimeout on the command object
var command = connection.CreateCommand();
command.CommandTimeout = 0;
//zero specifies never timeout.
//Any number greater than zero is the number of seconds before
//the command will time out.