Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stored procedure called from C# executes 6 times longer than from SQL Management studio

I have search stored procedure which is my performance bottleneck.

In order to get control about what is happened, I added logging for all parameters and also execution time in SP.

I noticed, that when I call SP from MIcrosoft SQL server management Studio execution time is 1.3-1.6 seconds, but when i call it from C#, it takes 6-8 secods (!!!)

Parameters                                                            | Time (ms)
"tb *"TreeType:259Parents:212fL:13;14fV:0;lcid:2057min:0max:10sort:-1 | 6406      
"tb *"TreeType:259Parents:212fL:13;14fV:0;lcid:2057min:0max:10sort:-1 | 1346      

SP is called with LINQ. Login settings are same. SP uses full text search

What could cause this?

like image 815
st78 Avatar asked Nov 06 '22 05:11

st78


1 Answers

In order to locate such issues, the best tool is SQL Profiler, which records the exact call to database.

For me the difference was with novalue passed by SQL sample, which was substituted by '' and null value passed by C#.

like image 75
st78 Avatar answered Nov 09 '22 16:11

st78