vscode-postgres
vscode-postgres copied to clipboard
Ability to stop / cancel long-running queries
Currently (1.1.16) there is no way of stopping a query (unless I'm mistaken). Queries which are ~~badly designed~~ roughly drafted and which run for a long time can be running in the background invisibly (sometimes locking resources on the database and stopping other queries completing) and there's no way of stopping them without going to the cmd line or pgadmin.
Obviously this is related to issue 52, in that you can't cancel a query unless you can see that it's running!
Many thanks for this extension - it is a godsend and my project members and I have been using it heavily for the last month or so.
I'll have to investigate cancelling of queries using the pg
package.
A little hesitant as when running a query - whether via the whole file, or just the selected query - it could contain multiple queries (one connection to the db and one request, multiple results). Cancelling could cause unintended side effects - though perhaps that is a decision left to the end user.
Thinking something like this for the UI: https://github.com/Microsoft/vscode-extension-samples/tree/master/progress-sample
Thanks for the reply - that UI works for me.
I hope I've understood your comments about multiple queries vs one cancellation - I would have thought that the desired behaviour would be whatever pgadmin would do. My guess is that queries in a multi-query request which have completed stay completed, but the query which was in progress at the time of the cancellation would not get committed. I think this is also what MS SQL does when you cancel long batches - hence the need for begin tran; commit tran;
syntax.
You understood it close enough. I've used pgadmin, but very limited (I came from MSSQL, and the management studio was sooo much nicer - and then decided I want the pg in my ide :) ), so I'm not 100% sure how pgadmin responds.
Right again about the begin tran; commit tran;
. I though about wrapping the query in that, but then though what if the query actually contained transactions.
If I leave it more and have queries "which have completed stay completed" - then its no transactions, and canceller beware. Makes it simpler - though still have to investigate just how to make the pg
node library cooperate with cancelling queries.