Connection timeout on query on large table

后端 未结 4 2035
难免孤独
难免孤独 2021-01-04 04:08

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

4条回答
  •  旧巷少年郎
    2021-01-04 05:03

    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.

提交回复
热议问题