hello niska,
can u please tell me what solution u have approached.
i am also having same problem as yours.
thanks
pranav
On Wednesday, February 23, 2011 7:30:05 PM UTC+5:30, niska wrote:
>
> What is the most efficient way to use the pool module with mysql? I'm not
> sure when I should release the connection. My questions are in the code
> below.
>
> var http = require('http'), poolModule = require('generic-pool');
>
> // create dbpool here using mysql module
>
> http.createServer(function (req, res) {
> dbpool.acquire(function(client) {
> client.query(
> 'SELECT ID FROM MAINTABLE',
> function (err, maintable) {
> if (err) {
> console.error(err.stack);
> *// 1. SHOULD I RELEASE HERE?*
> return;
> }
> * // 2. SHOULD I RELEASE HERE?*
> for (var i=0; i< maintable.length; i++) {
> *// 3. DO I NEED TO ACQUIRE NEW CLIENT HERE. OR CAN I REUSE OLD CLIENT?*
> client.query(
> 'SELECT * FROM ANOTHERTABLE WHERE MYID = ?',
> [maintable.ID]
> function (err, anothertable) {
> if (err) {
> console.error(err.stack);
> return;
> }
> // another loop here
> *// this one takes up to several seconds to complete! If possible I want
> to release the client so that it can be used by others...*
> }
> );
> }
> *// 4. SHOULD I RELEASE HERE?*
> ...
> ...
>
>
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.