I'm writing a web site with nodejs 0.8, express 3, jade, and a PostgreSQL 9 database. I had wanted to use a nosql database like mongodb which seemed like a natural fit, but I have been asked to use postgres because we already run a postgres server. I've used MySQL years ago but hadn't used postgres and am now learning about its capabilities.
For a particular page, I need to pull a lot of little bits of information from the database: the document itself; information about all the tags applied to the document; information about all of the document's authors; information about all of the licenses under which the document is available; information about a few different types of related documents. At the moment I'm using a single complicated query which uses views, common table expressions, sub-selects, array columns... It works, and is fast on my development machine, but I'm unsure if it's the best strategy or how it will perform under load. Particularly, I'm worried that as I want to add even more information to the page, statements like this will become slower and also more difficult for other fellow developers to understand. I'm already having to use some constructs that seem weird to me, like "SELECT array_to_json(ARRAY(SELECT ...)) ...", and then some post-processing in JavaScript to put the final result object together. Is there any common wisdom about whether it would be better / faster / more efficient to instead issue several smaller queries? I did not initially use that strategy because I thought it would be best to minimize the number of queries to avoid unnecessary overhead associated with each query, but now that I think about it, with node I would be issuing all of the queries at the about same time, and as the results from the simpler queries come in, I could already begin processing them, instead of having to wait for the whole result. And if the database server is multicore then wouldn't several smaller queries put those cores to better use? I guess I'm looking for real world anecdotes and experience from others who have already built node apps using SQL databases. Thanks and happy holidays. -- 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
