Skip to content

Optional support for results as arrays. #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Optional support for results as arrays. #324

wants to merge 1 commit into from

Conversation

mkleehammer
Copy link

Hi,

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 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
Copy link
Owner

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
Copy link

runk commented May 17, 2013

Any updates? Looking forward to have this feature also.

@brianc
Copy link
Owner

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
Copy link
Contributor

strk commented May 23, 2013

Support for this will be very welcome +1

@brianc
Copy link
Owner

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
Copy link
Contributor

strk commented May 29, 2013

What about also adding a "rowDecription" event ?

@brianc
Copy link
Owner

brianc commented Jul 8, 2013

Working on this now:

https://github.com/brianc/node-postgres/tree/issues/324

Also added field information to result object.

brianc added a commit that referenced this pull request Jul 10, 2013
add support for result rows as arrays
@brianc
Copy link
Owner

brianc commented Jul 10, 2013

closed in #393

@brianc brianc closed this Jul 10, 2013
@runk
Copy link

runk commented Jul 10, 2013

@brianc nice one! 💯

@brianc
Copy link
Owner

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants