On Feb 23, 8:39 pm, JeffreyM <
jeffrey.mcdonn...@gmail.com> wrote:
> A few things... First, the need to use a connection pool is mitigated (in
> most cases) by the fact that Node is not multi-threaded.
As you can see I have a http server running. If every request to the
server needs a connection, doesn't that mean that a connection pool
will help? Do you recommend creating a new connection for every
request?
> Second, I would
> give some consideration to reworking your queries to avoid querying within a
> loop. The comment "*this one takes up to several seconds to complete"* should
> raise serious concerns with the current design. Not being familiar with
> your schema, I cannot offer specific advice, but... I suspect you could JOIN
> "MAINTABLE" with "ANOTHERTABLE" in such a way that would avoid multiple
> queries or, at the very lease, a query within an O(n) loop.
The "thing" that takes time is actually a http request using the
request module by mikeal. The url is stored in the table. I get about
10 urls from the database using a select query. And in the resulting
loop I make a http request for each url.
Even if I make a join, it seems to me that I still have a problem with
an open connection until all requests to the urls are done. Or is
there a better way?
BTW: What is a "O(n) loop"?