If SQL is used directly or created by NHibernate, with possibly big "where in / not in ([1 to 100 parameters])" conditions, does it make sense to fill up parameters to certain limits, to have a limited number of query plans?
Parameters are int/number, DBMS is MSSQL or Oracle. The queries are called via sp_executesql/executeimmediate to enforce query plan caching.
Normally, such a query would have up to 100 query plans for the same query. Several such queries might quickly fill up the cache, or result in poor performance by not using cached query plans at all.
A user may fill up the parameter list by repeating the last value, until a certain number of parameters is reached?
As far as I know, MSSQL and Oracle identify known queries by string equality, resulting in a different query plan for each different number of parameters.
(values would of course be parameters and not concatenated numbers).
SELECT * FROM MyTable WHERE Id in (4001, 4002, 4003, ... , 4055, 4056)
with 56 parameters, change to:
SELECT * FROM MyTable WHERE Id in (4001, 4002, 4003, ... , 4055, 4056, 4056, 4056, 4056, 4056)
having 60 parameters by repeating value 4056, with all long "in" lists having lengths of 50, 60, 70, 80, 90, 100. Only less than 10 params will be left.
For such a query with up to 100 parameters, there would be 10 query plans for 10 to 100 parameters, plus 9 query plans for 1 to 9 parameters (no fill).