Re: odbc resources
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Nov 14, 2005
- 485 views
Craig Welch wrote: > > I'm experimenting with odbc, with SQL Server behind it. I'm running a > program to read in a 30,000 record file line by line, and insert it into > a table. (I know there are better ways of doing that, but it's a > learning exercise, both for odbc and SQL). > > The data are the test records that come with the Tsunami database. > > As the record count increases, the PC slows considerably, paging goes > through the roof, and eventually it's processing 4 transactions per > second. It starts at about 500 per second. > > I put in an abend statement after 10,000 records. Here is a section of > the dump that makes me wonder: > > handle_odbc = {9501740,9501900,-1} > handle_children = { > {2}, > {3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, > 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, > 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, > 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, > 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, > 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, > 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, > 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, > 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, > 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, > 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, > 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, > 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, > > etc ... to the limit that ex.err will display. > > Any thoughts? OK, I think I know what's happening. I'm not reusing the bookkeeping sequence handle_children properly. Here's what the end of allocHandleODBC() should look like:
if parent then -- try to reuse the children handles: ix = find( -1, handle_children[parent] ) if not ix then handle_children[parent] &= id else handle_children[parent][ix] = id end if handle_parent[id] = parent end if return id end function
...and the for-loop in the middle of freeHandleODBC():
for i = 1 to length( handle_children[id] ) do freeHandleODBC( handle_children[id][i] ) -- mark this as ready for reuse handle_children[id][i] = -1 end for
Matt Lewis