PERFORMANCE ADD NAMED PARAMETERS
Posted: Tue 06 May 2008 15:40
Hello everybody,
I have a problem with named uniparameters, exactly in performance when add new parameters.
I implemented a simple application that insert a 300 fields in one table with 32 columns. For to do this, I use the UniConnection and UniCommand (ExecuteNonQuery) components of CoreLab.
Firstly I construct all text without parameters (insert into tablex(ID,ID2,NAME...) values (1,2,'aa',...)) and the test is good (1-2 seconds).
Later I use Named Parameters (insert into tablex(...) values (:ID,:ID2,:NAME,...))and the performance loss:
- if I use 1 Parameters the time of execution is 1-2 seconds
- if I use 2 Parameters the time of execution is 3-4 seconds
- if I use 3 Parameters the time of execution is 5-6 seconds
- if I use 4 Parameters the time of execution is 6-7 seconds
- if I use 5 Parameters the time of execution is 8-9 seconds
- if I use 10 Parameters the time of execution is 17-18 seconds
- if I use 32 Parameters (all columns) the time of execution is 1 minute!!
At the same time, another departament do the same test using the DBExpress CoreLab for Delphi and the performance is good (1-2 seconds).
I pass our the function that create and add the named parameters:
public override void SetValueTo(UniParameterCollection pSqlParameters, string pParamName)
{
UniParameter vParameter;
if (!ReferenceEquals(pSqlParameters, null))
{
//check is value is null
if (IsNull)
vParameter = new UniParameter(pParamName, DBNull.Value);
else
{
vParameter = pSqlParameters.Add(pParamName, UniDbType.Int);
vParameter.Value = vValue;
}
pSqlParameters.Add(vParameter);
}
else
throw new Exception("Sql Parameters not assigned");
}
}
if I comment the "pSqlParameters.Add(vParameter);" line, the execution very quick.
Thanks for our attention.
I have a problem with named uniparameters, exactly in performance when add new parameters.
I implemented a simple application that insert a 300 fields in one table with 32 columns. For to do this, I use the UniConnection and UniCommand (ExecuteNonQuery) components of CoreLab.
Firstly I construct all text without parameters (insert into tablex(ID,ID2,NAME...) values (1,2,'aa',...)) and the test is good (1-2 seconds).
Later I use Named Parameters (insert into tablex(...) values (:ID,:ID2,:NAME,...))and the performance loss:
- if I use 1 Parameters the time of execution is 1-2 seconds
- if I use 2 Parameters the time of execution is 3-4 seconds
- if I use 3 Parameters the time of execution is 5-6 seconds
- if I use 4 Parameters the time of execution is 6-7 seconds
- if I use 5 Parameters the time of execution is 8-9 seconds
- if I use 10 Parameters the time of execution is 17-18 seconds
- if I use 32 Parameters (all columns) the time of execution is 1 minute!!
At the same time, another departament do the same test using the DBExpress CoreLab for Delphi and the performance is good (1-2 seconds).
I pass our the function that create and add the named parameters:
public override void SetValueTo(UniParameterCollection pSqlParameters, string pParamName)
{
UniParameter vParameter;
if (!ReferenceEquals(pSqlParameters, null))
{
//check is value is null
if (IsNull)
vParameter = new UniParameter(pParamName, DBNull.Value);
else
{
vParameter = pSqlParameters.Add(pParamName, UniDbType.Int);
vParameter.Value = vValue;
}
pSqlParameters.Add(vParameter);
}
else
throw new Exception("Sql Parameters not assigned");
}
}
if I comment the "pSqlParameters.Add(vParameter);" line, the execution very quick.
Thanks for our attention.