Skip to content
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

Maintain active connection rather than connecting each time to enable a more "interactive" mode #222

Open
drub0y opened this issue May 2, 2023 · 1 comment

Comments

@drub0y
Copy link

drub0y commented May 2, 2023

Currently Database::runQuery creates a new connection to the database every single time. This means you are starting a fresh session every time you run something which means that you can't change properties in the session and run some queries, maybe change some more session properties, run some more queries etc. This forces you to always run a set of commands to prepare your session each time rather than a more "interactive" mode.

A solution to this would be to actually maintain a set of open connections per document URI and simply handle graceful detection of closed connections and reopen them, if necessary, behind the scenes. It would also remove the overhead associated with having to establish a new connection each and every time a query is run which, when you're trying to iterate rapidly, adds up over time.

@Borvik
Copy link
Owner

Borvik commented Jun 30, 2023

I can understand the benefit of a continuous session, and the overhead it takes to establish the new connections.

During the initial design I gave some thought to this but rejected it for a couple of reasons.

  1. I often worked in a mixed environment, and as I worked if I would leave my tab open and it's connection, and then in another client tried to do something - I would often receive an error that another connection was preventing me from doing it. Then it was matter of trying to hunt down the window/tab that had the active connection and terminating it.

  2. Memory usage. Keeping a connection open keeps memory allocated. Running postgres/docker/test app/vscode all on the same machine uses a lot of memory (I routinely hit 25-30 GB of used memory), and each connection causes both postgres and the vscode to hold more memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants