db
db copied to clipboard
Reduce number of binding parameters
We can reduce the number of binding parameters by binding only values that need to be quoted (string and binary values).
It is not necessary to bind null, bool, int and float, these values can be converted to an unquoted string.
Expect this to improve performance slightly.
Related issue
- https://github.com/yiisoft/db/issues/888
It is not necessary to bind null, bool, int and float, these values can be converted to an unquoted string.
Expect this to improve performance slightly.
Why do you think so?
@xepozz about these being unnecessary or about performance?
About unnecessary binding for null, bool, etc
Well, it might be good to bind it for database optimizer but security-wise binding is not needed.
It is not necessary to bind null, bool, int and float, these values can be converted to an unquoted string. Expect this to improve performance slightly.
Why do you think so?
- The answer is in the sentence: "these values can be converted to an unquoted string" and it is safely.
- Less calls of methods and less stored values should improve performance.
I'm just wondering why should changing q=select ?, ?, ?, p=[null,1,true] to q=select null, 1, true, p=[] improve performance?
Anyway, we can test it
#888 counts the number of bound parameters, and solving this issue will potentially make this counting more complicated. Not fatal complexity, though.
Wow, that's an unexpected result. It works 3 times faster 🚀