Optional support for results as arrays. #324

wants to merge 1 commit into


4 participants


This commit adds support for a new config attribute rowtype which can be set to "array". If done, each row is an array of values instead of a full object. This has had enormous performance benefits for a couple of projects that sent a lot of rows to a client for processing. (The client side also maintained the values as arrays.) It is also much more convenient for working with some graphing libraries such as flot.

Since the field names are not part of the rows when this is enabled, the ones already attached to the result (_fieldNames) were made publicly accessible.

I've been using this for a few weeks, primarily for pages that return multiple query results in one page during initialization (lots of tables and graphs) and seems solid.

Added support for results as arrays. Added result.fieldNames.
Added support to return each row as an array instead of an object, which can
provide large performance benefits for large numbers of rows.  Enabled by
setting the new rowtype attribute to 'array'.

Made the field names a public part of the results, needed since they are not
part of each row.

brianc commented Apr 11, 2013

I like this, appreciate the pull request, and will merge this. I'm going to tweak the code style a bit to bring it more in line with the rest of the library. There was a time when I was busy w/ personal stuff & didn't have a lot of time to work on node-postgres I would merge things without changing the style. Now going back there are sections of the code that look strange to me so I'm going to try to maintain a more consistent style. Anyways...this looks good 👍

runk commented May 17, 2013

Any updates? Looking forward to have this feature also.


brianc commented May 17, 2013

@runk thanks for the nudge - sorry I dropped out on this one - I'll get to this right now.


strk commented May 23, 2013

Support for this will be very welcome +1


brianc commented May 23, 2013

just an update - I have this in a feature branch locally. Once it's solid it will land. Things are going slow for various reasons including vacation & new job etc. I haven't forgotten & apologize again for the delay.


strk commented May 29, 2013

What about also adding a "rowDecription" event ?


brianc commented Jul 8, 2013

Working on this now:


Also added field information to result object.

brianc added a commit that referenced this pull request Jul 10, 2013

Merge pull request #393 from brianc#324
add support for result rows as arrays

brianc commented Jul 10, 2013

closed in #393

@brianc brianc closed this Jul 10, 2013

runk commented Jul 10, 2013

@brianc nice one! 💯


brianc commented Jul 10, 2013

@runk sorry it took so long! Been so busy with everything, but I'm trying to spend some time early mornings working on bug fixes & patches. 🕐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment