-
Notifications
You must be signed in to change notification settings - Fork 7
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
Closing a DuckDBInstance? #122
Comments
There isn't currently a way to explicitly close an instance. However, it will be closed automatically a short time after the reference goes out of scope (and thus gets garbage collected). This typically happens in under a second, but does depend on the GC behavior so can't be strictly guaranteed. It wouldn't be hard to expose explicit close for instances - I did this already for connections - but I'm curious about the use case. It's not recommended in general to create more than one instance per process, either at the same time or over time. In which case would you call an explicit close, if it existed? |
Thanks for the answer, @jraymakers ! I’m currently updating my library, simple-data-analysis, with duckdb-node-neo I just noticed that I had a method for closing an instance with the previous bindings, which is why I’m asking. But if it’s closed automatically, I guess it’s all good! Thank you for all your hard work. This is a fantastic improvement! 😊 |
I might add it at some point if I get enough requests. Let me know if you find a need for it. I'll leave this open in the meantime. Glad you're enjoying the new library! |
It is recomendable hold connection open vs. open and close when needed? |
Connections in DuckDB (and Node Neo) are fairly lightweight compared to other DBMSs. They're just in-memory objects. I'd usually recommend keeping them around. The only reason I can think of to close one is to release any memory associated with it. This is usually small, but it can get large if you create (large) temporary objects, because these are associated with the connection. Other semantic properties of connections might affect your decision of how many to use:
|
Hi!
With the previous DuckDB node bindings, we could
.close()
a Database instance to free up memory.Is there a way to do the same thing with this version?
Thank you!
The text was updated successfully, but these errors were encountered: