You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When FirebirdSql.Data.FirebirdClient is used to insert a lot of records in a table using parametred query, it's possible to gain time in the FbCommand.UpdateParameterValues :
Change this code :
for (int i = 0; i < this.statement.Parameters.Count; i++)
{
index = i;
if \(this\.namedParameters\.Count \> 0\)
\{
index = this\.Parameters\.IndexOf\(this\.namedParameters\[i\]\);
if \(index == \-1\)
\{
throw new FbException\(String\.Format\("Must declare the variable '\{0\}'", this\.namedParameters\[i\]\)\);
\}
\}
by this one :
for (int i = 0; i < this.statement.Parameters.Count; i++)
{
index = i;
if \(this\.namedParameters\.Count \> 0\)
\{
if \(this\.Parameters\[i\]\.ParameterName \!= this\.namedParameters\[i\]\) // Added by webpac
\{
index = this\.Parameters\.IndexOf\(this\.namedParameters\[i\]\);
if \(index == \-1\)
\{
throw new FbException\(String\.Format\("Must declare the variable '\{0\}'", this\.namedParameters\[i\]\)\);
\}
\}
\}
And then, if the namedParamers[i] is the same then Parameters[i], it doesn't looking for all nameParameters.
I tried to insert 1000 records with 50 parameters, without the optimisation, it dures 10 seconds and with the optimisation it dures 7 seconds.
I didn't look at all the source code to understand the différences between parameters and namedparameters.
I think it's possible that is the only performance issue when trying to find the good parameter.
But it's possible that using a dictionary will guard to do possible others performance issues so it's a good idea to use a dictionary.
Still not sure the dictionary is worth it, because the method is called with every execution and hence the dictionary will be recreated every time.
Your check is good idea for fast-path. But needs to respect the logic of IndexOf, hence easy to break. Maybe now, with the internal changes, it will be OK.
Submitted by: Pascal (webpac)
When FirebirdSql.Data.FirebirdClient is used to insert a lot of records in a table using parametred query, it's possible to gain time in the FbCommand.UpdateParameterValues :
Change this code :
for (int i = 0; i < this.statement.Parameters.Count; i++)
{
index = i;
by this one :
for (int i = 0; i < this.statement.Parameters.Count; i++)
{
index = i;
And then, if the namedParamers[i] is the same then Parameters[i], it doesn't looking for all nameParameters.
I tried to insert 1000 records with 50 parameters, without the optimisation, it dures 10 seconds and with the optimisation it dures 7 seconds.
Regards,
Commits: ac85e41
The text was updated successfully, but these errors were encountered: