Fix performance bug with large number of unnamed parameters
On some occasions where col in (:args) contain a really lot args, 10k+ for instance, this commit fixes a performance (high CPU) bug by NOT traversing the whole map in basically O(n^2) manner Signed-off-by: Mikhail Fedorov <mfedorov761@gmail.com> Squashed by Jens Schauder Original pull request #2050
This commit is contained in:
committed by
Jens Schauder
parent
520d6a7d4d
commit
58a3f01ccd
@@ -53,6 +53,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
* @author Yan Qiang
|
||||
* @author Mikhail Fedorov
|
||||
* @since 3.0
|
||||
*/
|
||||
public class QueryMapper {
|
||||
@@ -632,7 +633,7 @@ public class QueryMapper {
|
||||
return name;
|
||||
}
|
||||
|
||||
int counter = 1;
|
||||
int counter = values.size();
|
||||
String uniqueName;
|
||||
|
||||
do {
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Jens Schauder
|
||||
* @author Mikhail Fedorov
|
||||
*/
|
||||
public class QueryMapperUnitTests {
|
||||
|
||||
@@ -121,7 +122,7 @@ public class QueryMapperUnitTests {
|
||||
Condition condition = map(criteria);
|
||||
|
||||
assertThat(condition).hasToString(
|
||||
"(person.\"NAME\" = ?[:name]) AND (person.\"NAME\" = ?[:name1] OR person.age < ?[:age] OR (person.\"NAME\" != ?[:name2] AND person.age > ?[:age1]))");
|
||||
"(person.\"NAME\" = ?[:name]) AND (person.\"NAME\" = ?[:name1] OR person.age < ?[:age] OR (person.\"NAME\" != ?[:name3] AND person.age > ?[:age4]))");
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-318
|
||||
|
||||
Reference in New Issue
Block a user