I know this is an old thread, and already addressed by more than one answer ... but I wanted to add one more consideration.
I found this thread because my C# app was executing fairly simple queries, but very slowly. While I was reading through this great info, I started a new query in my app ... and it resolved nearly immediately.
What had changed? I'd closed the Discord app. Could be a memory usage issue, I suppose, but I'm willing to just blame Discord for being a resource hog. :)
Sharing this in case it helps anyone else in my situation...