tediousjs / node-mssql

Microsoft SQL Server client for Node.js
https://tediousjs.github.io/node-mssql
MIT License
2.22k stars 464 forks source link

Potential impact of disabling connection validation when released from the pool #1614

Closed mderriey closed 3 months ago

mderriey commented 4 months ago

This is not a bug report, but a question.

We have an app that uses TypeORM against SQL Server, so it uses mssql under the hood. We noticed that each query the app issues is preceded by a SELECT 1 query.

After some research, we found that this logic is enabled by default in mssql, and makes sure that the connection we got from the pool is healthy before using it for the end-user query.

Our understanding is that this could improve robustness as if a connection is found to be in a bad state when released from the pool, it's replaced transparently to us.

However, we have a system that issues a bunch of queries, and the latency to the SQL instance is variable, so every bit counts.

We were wondering what the impact of disabling this would be, and if you had pointers as to how we could handle these situations gracefully.

Thanks a lot in advance.

dhensby commented 4 months ago

Disabling the connection validation shouldn't make a big difference. You'll just need some robust error handling in the event a connection has gone bad; that could be as simple as query retries when you see an underlying connection error.