Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
I hate that these things exist...
I meant the whole situation! The fixes are warranted and they work, no problemo.
It's just that it's a pretty complicated chain of events and I can get stuck when debugging that deep, so I might just rewrite the query to get it to work and move on to the next task... But I always get this bad feeling that something magical just happened behind the scenes but I couldn't catch it. I hate not knowing why acts in a strange (and therefore interesting) fashion, but there's so much pressure to just work around it and churn out a feature. There are some weird behaviors that I never could get to the bottom of and it haunts me.
I know that computers aren't magical, there has to be an explanation. I NEED to know. But I eventually have to let it go, which sucks. Oh, a side project is a good outlet for these things. I guess there are more fun things than hard-to-debug problems but you always learn sooo much from it.
TL;DR : The SQL server will compile your stored procedure (In my case the EF queries) for the first parameters it receives. And it doesn’t care about next batch of parameters.
I still struggling to understand: WHY ?
We have multi-tenant DB for clients. Some clients represent 100 rows in database. Some more than 100.000. And SQL server manages them… with parameters received on the first execution of the query. So if a “big” client uses a future first, he’ll never have a problem. If for some reason Querry store is reset and a small uses the same feature: Well, yep it’s going to optimize the execution plan. And use it for the big client too. And big client will.. timeout
For me too.
Go back 3 weeks :
One client: This page is not loading.
I’m checking. Yes, the query is timing out (30 sec).
First try : Write manual query. Execution: Instant. (0.01 seconds)
Me : Hmmmm, EF must’ve messed up query generation.
Intercepting EF generated query. Run it again (In production of cause). Same : 0.01 sec.
Me : WTF ?
Modifying query just a little. Added an empty check “true == true” in “where” clause.
EF execution: 0.01 sec.
Me ; ??????????
Finally tracked the problem. If you want to search more : google SQL Parameters sniffing.
Well theres your problem right there! Just migrate to Postgres and everything will be solved! /s
Seriously though postgres is really good
Your Job Suck?
Take a quick quiz from Triplebyte to skip the job search hassles and jump to final interviews at hot tech firms
Get a Better Job