To be honest I find it odd, that the power of two padding only applies per inclause. I feel like a better approach would be to just always use a power of two many bind variables, even if that means generating one or more inclause with only null parameters. I mean why should inExprLimit}}affect the number of bind variables used. That doesn’t make any sense to me. The padding is supposed to avoid statement cache polution in the database, so i would expect a statement with 10001 values to use the same number of bind variables as a statement with 10002 parameters, regardless of whether {{inExprLimit is set to 0 or 1000. I would want 16384 bind variables in both cases. So in my opinion the calculation should really be as simple as this:
private static int calculateLastInClauseSize(int bindValueCount, int inExprLimit) {
int lastInClauseSize = ceilingPowerOfTwoFixed(bindValueCount);
if (inExprLimit > 0) {
lastInClauseSize %= inExprLimit;
}
return lastInClauseSize;
}
|