Skip to content

Commit

Permalink
Merge pull request #3057 from showkawa/#3056_performance_issue
Browse files Browse the repository at this point in the history
#3056 performance issue
  • Loading branch information
chuntaojun authored Jun 14, 2020
2 parents 147e3f9 + 8c0f52f commit 34fda6a
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ public Page<ConfigInfo> findConfigInfo4Page(final int pageNo, final int pageSize
}
PaginationHelper<ConfigInfo> helper = createPaginationHelper();
return helper
.fetchPage(sqlCount + where, sql + where, paramList.toArray(), pageNo,
.fetchPage(sqlCount + where.toString(), sql + where.toString(), paramList.toArray(), pageNo,
pageSize, CONFIG_INFO_ROW_MAPPER);
}

Expand Down Expand Up @@ -1597,7 +1597,7 @@ public Page<ConfigInfo> findConfigInfoLike(final int pageNo, final int pageSize,
final ConfigKey[] configKeys, final boolean blacklist) {
String sqlCountRows = "select count(*) from config_info where ";
String sqlFetchRows = "select ID,data_id,group_id,tenant_id,app_name,content from config_info where ";
String where = " 1=1 ";
StringBuilder where = new StringBuilder(" 1=1 ");
// White list, please synchronize the condition is empty, there is no qualified configuration
if (configKeys.length == 0 && !blacklist) {
Page<ConfigInfo> page = new Page<ConfigInfo>();
Expand All @@ -1619,74 +1619,74 @@ public Page<ConfigInfo> findConfigInfoLike(final int pageNo, final int pageSize,
if (blacklist) {
if (isFirst) {
isFirst = false;
where += " and ";
where.append(" and ");
}
else {
where += " and ";
where.append(" and ");
}

where += "(";
where.append("(");
boolean isFirstSub = true;
if (!StringUtils.isBlank(dataId)) {
where += " data_id not like ? ";
where.append(" data_id not like ? ");
params.add(generateLikeArgument(dataId));
isFirstSub = false;
}
if (!StringUtils.isBlank(group)) {
if (!isFirstSub) {
where += " or ";
where.append(" or ");
}
where += " group_id not like ? ";
where.append(" group_id not like ? ");
params.add(generateLikeArgument(group));
isFirstSub = false;
}
if (!StringUtils.isBlank(appName)) {
if (!isFirstSub) {
where += " or ";
where.append(" or ");
}
where += " app_name != ? ";
where.append(" app_name != ? ");
params.add(appName);
isFirstSub = false;
}
where += ") ";
where.append(") ");
}
else {
if (isFirst) {
isFirst = false;
where += " and ";
where.append(" and ");
}
else {
where += " or ";
where.append(" or ");
}
where += "(";
where.append("(");
boolean isFirstSub = true;
if (!StringUtils.isBlank(dataId)) {
where += " data_id like ? ";
where.append(" data_id like ? ");
params.add(generateLikeArgument(dataId));
isFirstSub = false;
}
if (!StringUtils.isBlank(group)) {
if (!isFirstSub) {
where += " and ";
where.append(" and ");
}
where += " group_id like ? ";
where.append(" group_id like ? ");
params.add(generateLikeArgument(group));
isFirstSub = false;
}
if (!StringUtils.isBlank(appName)) {
if (!isFirstSub) {
where += " and ";
where.append(" and ");
}
where += " app_name = ? ";
where.append(" app_name = ? ");
params.add(appName);
isFirstSub = false;
}
where += ") ";
where.append(") ");
}
}
PaginationHelper<ConfigInfo> helper = createPaginationHelper();
return helper
.fetchPage(sqlCountRows + where, sqlFetchRows + where, params.toArray(),
.fetchPage(sqlCountRows + where.toString(), sqlFetchRows + where.toString(), params.toArray(),
pageNo, pageSize, CONFIG_INFO_ROW_MAPPER);

}
Expand Down Expand Up @@ -1769,7 +1769,7 @@ public Page<ConfigInfoAggr> findConfigInfoAggrLike(final int pageNo,

String sqlCountRows = "select count(*) from config_info_aggr where ";
String sqlFetchRows = "select data_id,group_id,tenant_id,datum_id,app_name,content from config_info_aggr where ";
String where = " 1=1 ";
StringBuilder where = new StringBuilder(" 1=1 ");
// White list, please synchronize the condition is empty, there is no qualified configuration
if (configKeys.length == 0 && blacklist == false) {
Page<ConfigInfoAggr> page = new Page<ConfigInfoAggr>();
Expand All @@ -1790,74 +1790,74 @@ public Page<ConfigInfoAggr> findConfigInfoAggrLike(final int pageNo,
if (blacklist) {
if (isFirst) {
isFirst = false;
where += " and ";
where.append(" and ");
}
else {
where += " and ";
where.append(" and ");
}

where += "(";
where.append("(");
boolean isFirstSub = true;
if (!StringUtils.isBlank(dataId)) {
where += " data_id not like ? ";
where.append(" data_id not like ? ");
params.add(generateLikeArgument(dataId));
isFirstSub = false;
}
if (!StringUtils.isBlank(group)) {
if (!isFirstSub) {
where += " or ";
where.append(" or ");
}
where += " group_id not like ? ";
where.append(" group_id not like ? ");
params.add(generateLikeArgument(group));
isFirstSub = false;
}
if (!StringUtils.isBlank(appName)) {
if (!isFirstSub) {
where += " or ";
where.append(" or ");
}
where += " app_name != ? ";
where.append(" app_name != ? ");
params.add(appName);
isFirstSub = false;
}
where += ") ";
where.append(") ");
}
else {
if (isFirst) {
isFirst = false;
where += " and ";
where.append(" and ");
}
else {
where += " or ";
where.append(" or ");
}
where += "(";
where.append("(");
boolean isFirstSub = true;
if (!StringUtils.isBlank(dataId)) {
where += " data_id like ? ";
where.append(" data_id like ? ");
params.add(generateLikeArgument(dataId));
isFirstSub = false;
}
if (!StringUtils.isBlank(group)) {
if (!isFirstSub) {
where += " and ";
where.append(" and ");
}
where += " group_id like ? ";
where.append(" group_id like ? ");
params.add(generateLikeArgument(group));
isFirstSub = false;
}
if (!StringUtils.isBlank(appName)) {
if (!isFirstSub) {
where += " and ";
where.append(" and ");
}
where += " app_name = ? ";
where.append(" app_name = ? ");
params.add(appName);
isFirstSub = false;
}
where += ") ";
where.append(") ");
}
}
PaginationHelper<ConfigInfoAggr> helper = createPaginationHelper();
return helper
.fetchPage(sqlCountRows + where, sqlFetchRows + where, params.toArray(),
.fetchPage(sqlCountRows + where.toString(), sqlFetchRows + where.toString(), params.toArray(),
pageNo, pageSize, CONFIG_INFO_AGGR_ROW_MAPPER);

}
Expand Down
Loading

0 comments on commit 34fda6a

Please sign in to comment.