Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use same parameter when value is the same #78

Closed
Gillardo opened this issue Sep 3, 2021 · 6 comments
Closed

Use same parameter when value is the same #78

Gillardo opened this issue Sep 3, 2021 · 6 comments

Comments

@Gillardo
Copy link

Gillardo commented Sep 3, 2021

If i create a query and pass in the same parameter value, it generates a new parameter for this. It would be much more efficient if the code only added 1 parameter for each unique value instead.

Can this be done?

@maxtoroq
Copy link
Owner

maxtoroq commented Sep 4, 2021

This could be done, but unless you are using a huge number of parameters, I don't see a big perf gain. It would also be a breaking change for code that depends on the number of parameters generated.

@Gillardo
Copy link
Author

Gillardo commented Sep 4, 2021

We are generating queries and putting them all together so it's only one database connection, I think this would be a good changed. At the moment it easily generates over 2000 parameters but it's around 4 values

@maxtoroq
Copy link
Owner

maxtoroq commented Sep 7, 2021

You can override the CreateCommand method on Database.

Another perf issue I can think of is parameter equality. Every time you add a parameter you have to check if it's equal to any of the previously added. That is unless you use something like a hash code.

@Gillardo
Copy link
Author

Gillardo commented Sep 8, 2021

What do u mean we can override the create command method on database?

@maxtoroq
Copy link
Owner

maxtoroq commented Sep 8, 2021

public virtual IDbCommand CreateCommand(string commandText, params object[] parameters) {

@maxtoroq
Copy link
Owner

Closing as this is a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants