chartjes/grumpy-node — pull request #1 by fritzy (2012-03-19 17:21:40+00:00)
Title: I made some suggested Changes

Howdy! Unfortunately, I didn't have a test DB, so this may blow up (parse errors, logic errors?).

Generally you want error first for callbacks. This makes using async libraries easier.

Otherwise, I broke up your while loop into a simple map-reduce in order to prevent long transaction results from blocking other requests.
This way, even if you had a billion results, you could process them and still serve other requests in the meantime (since we're calling a function for each row), assuming you had enough memory. The other way to do this might be using your while loop, but batching groups of rows out to a processing function.