I have a similar issue - queries are suspended randomly, sometimes they are fast and sometimes suddenly suspended.
My case is:
- console app1 reading from database.
- console app2 which calls app1 to get and use data received from database.
Observations:
- query is fast when call directly in SSMS;
- query is fast when run app1 separately;
- query is suspended sometimes when app2 calls app1.
I asked GitHub Copilot if VPN can be the reason. Here is the response:
Yes, the VPN can absolutely be a factor—even if your database is local.
Why VPN Can Affect Local Database Performance
• Network Routing: When connected to a VPN, all your network traffic (sometimes including local traffic) may be routed through the VPN tunnel. This can introduce latency, packet loss, or even block certain local network connections, depending on VPN configuration.
• DNS Resolution: VPNs can change your DNS settings, which might affect how "localhost" or your machine's name resolves.
• Firewall/Policy Changes: Some VPNs enforce strict firewall rules or network isolation, which can interfere with local connections.
• Split Tunneling: If your VPN does not use split tunneling, even local traffic may be forced through the VPN, slowing down access to local resources.
Why It Might Seem Random
• VPN routing and policies can change dynamically.
• Some VPN clients intermittently enforce different rules or routes.
• If your database connection string uses a hostname instead of localhost or 127.0.0.1, DNS or routing issues may be more likely.
What To Check
• Connection String: Ensure you are using localhost or 127.0.0.1 for local databases.
• VPN Settings: Check if your VPN client has options for split tunneling or local network access.
• Network Interfaces: When VPN is connected, run ipconfig (Windows) or ifconfig (Linux/Mac) to see if your local network interface is still active and prioritized.
Summary
Even for a local database, a VPN can introduce delays or connection issues. If your queries are fast when not using VPN, it's very likely the VPN was causing the problem.
Recommendation:
If you must use VPN, configure it to allow local network access or use split tunneling. Otherwise, disconnect from VPN when working with local resources for best performance.
Finally enabling split tunneling resolved the issue.