yiisoft / db

Yii Database Library
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
134 stars 35 forks source link

Reduce number of binding parameters #893

Open Tigrov opened 4 weeks ago

Tigrov commented 4 weeks ago

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

xepozz commented 4 weeks ago

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?

samdark commented 3 weeks ago

@xepozz about these being unnecessary or about performance?

xepozz commented 3 weeks ago

About unnecessary binding for null, bool, etc

samdark commented 3 weeks ago

Well, it might be good to bind it for database optimizer but security-wise binding is not needed.

Tigrov commented 3 weeks ago

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?

  1. The answer is in the sentence: "these values can be converted to an unquoted string" and it is safely.
  2. Less calls of methods and less stored values should improve performance.
xepozz commented 3 weeks ago

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