I appears that using bind variables in my queries is hurting performance, some examples by as much as a factor of 5. The following example takes on average about 0.5 seconds to complete.
string strId = "abcd";
using (var db = _conn.OpenDbConnection())
{
var sql = "SELECT count(*) FROM table WHERE idNum= :ID";
var r = db.QueryScalar<int>(sql, new { ID = strID.ToUpper() });
return r >= 1;
}
When I run the following code it takes around 0.1 seconds to complete.
string strId = "abcd";
using (var db = _conn.OpenDbConnection())
{
var sql = string.Format("SELECT count(*) FROM table WHERE idNum= '{0}'", strID.ToUpper());
var r = db.QueryScalar<int>(sql);
return r >= 1;
}
Am I using something incorrectly here that is causing the performance issue?
This is in C# against an Oracle database using version 3.9.71.0 of ServiceStack.OrmLite