Skip to content

Confused: connect or not to connect? #1151

@davidgatti

Description

@davidgatti

Hello,

In the project that I'm working on, instead of using Sequalize I decided to do old school, since the project is small. This means I'm spending lots of time in this repo 👻 😋. And I'm confused how to talk with the DB.

On the main README.md I read:

//call done() to release the client back to the pool

So my brain assumes that not only I have to do connect() at each request, but I also have to release the connection. Sounds fine to me.

But then I go hear https://github.com/brianc/node-postgres/wiki/Query, and suddenly no connection(), and no release to be seen in the top part of the document.

In my code I made queries using both options and they work, but since I don't see the difference I don't know which one to chose :)

How should I talk with the DB? 😎 To many options, and not enough explanation on the differences between all this approaches.

What I'm looking for:

  • to write as little code as possible
  • to have code that can handle 10,000 request a minute for example.
  • to reuse the open connection as much as possible.

Which aproceh will give the best results?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions