For example, I have two logically equivalent constructions:
getRows("SELECT * FROM foo WHERE id IN (1, 12, 23, 34, 45, 56, 67, 78, 89, 100)");
QueryStatistics internally: totalExecutionTime = 2100, executionCount = 1000 As result: getExecutionAvgTime() * getExecutionCount() = int(2100 / 1000) * 1000 = 2 * 1000 = 2000 ms
for (int id : new int[] {1, 12, 23, 34, 45, 56, 67, 78, 89, 100}) { getRow("SELECT * FROM foo WHERE id = ?", id); }
QueryStatistics internally: totalExecutionTime = 9000, executionCount = 10000 As result: getExecutionAvgTime() * getExecutionCount() = int(9000 / 10000) * 10000 = 0 * 10000 = 0 ms
As a result, according to statistics slower version is a more rapid as performed instantaneously.