Reputation: 2749
[using the JavaScript driver]
I've seen on several of the rethinkdb
example projects that connections are closed at the end of each query (e.g., conn.close()
)
While I understand the pedagogical reasons to include that in the tutorials, is it actually performant to manually close connections? I am under the impression that the connection will automatically close once it is out-of-scope
Upvotes: 0
Views: 128
Reputation: 39
You should not leave connections open..
You should:
1) Open connections as late as possible
2) Close connections as soon as possible
The connection itself is returned to the connection pool. Connections are a limited and relatively expensive resource. Any new connection you establish that has exactly the same connection string will be able to reuse the connection from the pool.
Upvotes: 1