c# - Using SQL Server "LEFT" function result in poor performance when running Batch data than without it -


while executing / processing batch dealer vehicles data using vin, noticed performance terribly slow. after benchmark testings, found if use t-sql function left, performance suffers if don't use it, works okay.

without t-sql function left, end average of 73 car dealers per minute. left, end average of 5 or 6 car dealers per minutes.

so what's problem , what's workaround problem? thanks.

using (var dbconnection = new sqlconnection(this._dbconnectionstring)) {     using (var dbcommand = dbconnection.createcommand())     {         sqlask = "";         sqlask += " select year, make, model, style trim, squish_vin squishvin, '' vehicleid ed_squish_vin_v3_90 ";         //@@sqlask += " @parmvehiclesquishvin = squish_vin ";         sqlask += " @parmvehiclesquishvin left(squish_vin, 9) ";          dbcommand.commandtext = sqlask;         dbcommand.parameters.clear();         dbcommand.parameters.add("@parmvehiclesquishvin", sqldbtype.varchar, 10, "squish_vin").value = squishvin;          if (dbconnection.state == connectionstate.open) { dbconnection.close(); }          dbconnection.open();          using (var dbreader = dbcommand.executereader())         {         }     } } 

when use function on column in clause index on column doesn't take effect means index has no use. can write query little bit differently remove use of left e.g.

  sqlask += " select year, make, model, style trim, squish_vin squishvin, '' vehicleid ed_squish_vin_v3_90 ";         //@@sqlask += " @parmvehiclesquishvin = squish_vin ";         sqlask += " squish_vin '"+squishvin+"%'"; 

this query should give exact same result without using left function. don't need use parameter in case


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -