Replace param placeholder from ?<number> to ? #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Performance Issues
We've noticed that
ClickhouseEcto
added a lot of overhead to insert times (compared todb=<num>ms
ecto times)Profiling revealed that
ClickhouseEcto.Connection.order_params/2
was responsible for almost 25-30% of execution time. (Regex.replace calls in particular)To eliminate the overhead, we've changed param placeholder format from
?1, ?2, ?3
to?
. And removedorder_params
as a result, because it was no longer needed.Need for ?1, ?2 params
We haven't noticed any regressions after removing ordered params, but to be sure, I've ported mysql unit tests from ecto.
There's a similar code in mssql ecto adapter that is required for
DATEADD
mssql functions to work.But we couldn't find any such cases in clickhouse_ecto, therefore we assumed that it was safe to remove ordered params completely.
Test app
I've created a test app to demonstrate the performance differences: https://github.com/scarfacedeb/clickhouse_ecto_test
A sample of the profiling results
Using
profile.fprof
with the following command:ClickhouseEcto 0.2.4:
Our fork without
order_params
: