This helps avoid creating a large number of different prepared statements.
Each query (prepared statement) needs to be parsed and its execution plan needs to be calculated and cached by the database. This process may be much more expensive than the actual execution of the query for which the statement has already been cached.
A large number of different statements may lead to purging other cached statements out of the cache, thus degrading the overall application performance.
Also, since hard parse is generally very expensive, it is usually faster to execute multiple cached prepared statements (including multiple database round trips) than to parse and execute a new one. So, besides the obvious benefit of reducing the number of different statements, it may actually be faster to retrieve all of the 119 entities by executing 11 cached statements than to create and execute a single new one which contains all of the 119 ids.
As already mentioned in the comments, Hibernate invokes ArrayHelper.getBatchSizes
method to determine the batch sizes for the given maximum batch size.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…