|
From: chedderslam on 24 Jun 2008 12:24 I can't get more than one query running at a time with the connection pooling I am trying to implement. I think I'm missing a step or the logic is flawed somewhere, but I can't see it. The first proc is called before running a query: ----------------------------------------------------------------------------------------------------------------- proc getconnection {} { variable ::requesthandler::connectionpool if { [llength $connectionpool] == 0 } { set db [msado #auto] $db configure \ -provider sqloledb \ -server SAM-WKHNCD94333 \ -database si_training_db \ -user sa \ -password nothing $db connect return $db } else { set db [lindex $connectionpool 0] set connectionpool [lrange $connectionpool 1 end] return $db } } ----------------------------------------------------------------------------------------------------------------- After the query is run, the next proc is called: ----------------------------------------------------------------------------------------------------------------- proc releaseconnection {db} { variable ::requesthandler::connectionpool lappend connectionpool $db } ----------------------------------------------------------------------------------------------------------------- So the use in the main proc looks something like this: ----------------------------------------------------------------------------------------------------------------- set db [getconnection] set query [$db new_query] $query configure -sql $sqlstring $query execute releaseconnection $db ----------------------------------------------------------------------------------------------------------------- All this works without error, but if I run a 15 second query through three page requests, the first page returns after 15 seconds, the second page returns after 30, and the third after 45. I know I'm missing something but can't see it.
From: David Gravereaux on 24 Jun 2008 12:43 chedderslam, On the surface, it looks like your system is still syncronous for running the query. Either run your server in threaded mode, or generate your page in two parts. With the first part initiating the DB query then dropping back into the server's notifier to service more pages. When the DB query completes, push the job into the server's service loop to pickup the connection object and finish the page generation. What server are you using?
From: chedderslam on 24 Jun 2008 12:51 > What server are you using? This is all in httpd server. Everything is called through a proc mapped to a url. Since each call to the proc happens via a page request, I would think that I would be able to create more than one connection to the db at a time. I thought it would be possible to create more than one object that connects to the db at a time. I would like to avoid making this multi-threaded for the time being. There are plans to do it in the future, just not this iteration of the code. I feel like it is possible to do what I want, but I'm just missing something. I could be totally wrong though. Thanks,
From: David Gravereaux on 24 Jun 2008 13:02 chedderslam wrote: >> What server are you using? > > This is all in httpd server. Everything is called through a proc > mapped to a url. Since each call to the proc happens via a page > request, I would think that I would be able to create more than one > connection to the db at a time. > > I thought it would be possible to create more than one object that > connects to the db at a time. > > I would like to avoid making this multi-threaded for the time being. > There are plans to do it in the future, just not this iteration of the > code. > > I feel like it is possible to do what I want, but I'm just missing > something. I could be totally wrong though. > > Thanks, > > Turn on threads. That part is easy. You can't not avoid it if you want multiple queries to run at the same time.
From: Alexandre Ferrieux on 24 Jun 2008 13:09 On Jun 24, 7:02 pm, David Gravereaux <davyg...(a)pobox.com> wrote: > chedderslam wrote: > >> What server are you using? > > > This is all in httpd server. Everything is called through a proc > > mapped to a url. Since each call to the proc happens via a page > > request, I would think that I would be able to create more than one > > connection to the db at a time. > > > I thought it would be possible to create more than one object that > > connects to the db at a time. > > > I would like to avoid making this multi-threaded for the time being. > > There are plans to do it in the future, just not this iteration of the > > code. > > > I feel like it is possible to do what I want, but I'm just missing > > something. I could be totally wrong though. > > > Thanks, > > Turn on threads. That part is easy. You can't not avoid it if you want > multiple queries to run at the same time.- Hide quoted text - Also, depending on the bandwidth requirements of your app, it could make sense to go the *much* simpler (though slower) route of CGI. Of course each request will spawn a fresh process, which will have to do its db init etc. but if all you want is the job to be done, and not within 0.5% of the optimum optimorum, CGI has the merit of simplicity. -Alex
|
Next
|
Last
Pages: 1 2 3 Prev: Wish failed to run over ssh -X Next: Oratcl and Oracle Instant Client issue |