microsoft / vscode-cosmosdb

Azure Databases extension for VS Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-cosmosdb
MIT License
155 stars 68 forks source link

perf: Use cached mongoDB connection #2255

Closed JasonYeMSFT closed 6 months ago

JasonYeMSFT commented 6 months ago

ext.rgApi.appResourceTree.findTreeItem() is a very slow API. If the underlying connection hasn't changed, the change avoids re-searching the tree for the node to allow almost instantaneous execution of the MongoDB commands in the scrapbook if a matching connection already exists. Otherwise, every command execution will have to wait for several seconds.

It's possible for a user to delete a database, recreate a new one with the same name to masquerade the old database and thus invalidate the connection. I think it's a rare case and the user can work around it by clicking the connect button to re-connect.