[Sqlrelay-discussion] Dynamic cursors patch
Brought to you by:
mused
|
From: Cal H. <ca...@fb...> - 2010-05-18 23:06:13
|
Hi everyone, Here's my patch against SQL Relay release 0.41 to implement dynamic cursors. This will allow you to start up connections with a small number of cursors, then grow them as needed until a defined maximum is reached. This is handy in the case of a few pages that might go crazy with the number of cursors needed. Sometimes it's difficult to track down where the leak is, so it's nice to have the server take care of this for you. (Without needing the memory bloat of many cursors across all connections) I added 2 new config file parameters to the *instance* tag: *maxcursors*: limit the maximum number of cursors to this number. Defaults to 1300. I'm not sure what other databases are like, but DB2 has a magic limit of 1326 statement handles. *cursors_growby*: When we need to allocate more cursors, add on a group of this many at a time. (Avoids many realloc() conditions under heavy use) Defaults to 5. The *cursors* parameter still behaves as usual, it starts up X number of initial cursors per connection. I did add one tiny bug fix to this as well -- it seems that the "times new cursor used" stat wasn't updated. I modified the behavior to increment the counter when the *client* requests a new cursor. (Even if the server has already allocated one) Please let me know if you find any bugs with this patch. Thanks, --Cal |