Optimizing paging parameters (#9487)

This commit is contained in:
李晓双 Li Xiao Shuang 2022-11-06 16:59:27 +08:00 committed by GitHub
parent 40519a22d5
commit 6849af1547
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 29 additions and 33 deletions

View File

@ -1427,9 +1427,8 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
String sqlCountRows = configInfoBetaMapper.count(null);
String sqlFetchRows = configInfoBetaMapper.findAllConfigInfoBetaForDumpAllFetchRows(startRow, pageSize);
PaginationHelper<ConfigInfoBetaWrapper> helper = createPaginationHelper();
return helper
.fetchPageLimit(sqlCountRows, sqlFetchRows, new Object[] {(pageNo - 1) * pageSize, pageSize}, pageNo,
pageSize, CONFIG_INFO_BETA_WRAPPER_ROW_MAPPER);
return helper.fetchPageLimit(sqlCountRows, sqlFetchRows, new Object[] {}, pageNo, pageSize,
CONFIG_INFO_BETA_WRAPPER_ROW_MAPPER);
}
@ -1441,9 +1440,8 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
String sqlFetchRows = configInfoTagMapper.findAllConfigInfoTagForDumpAllFetchRows(startRow, pageSize);
PaginationHelper<ConfigInfoTagWrapper> helper = createPaginationHelper();
return helper
.fetchPageLimit(sqlCountRows, sqlFetchRows, new Object[] {(pageNo - 1) * pageSize, pageSize}, pageNo,
pageSize, CONFIG_INFO_TAG_WRAPPER_ROW_MAPPER);
return helper.fetchPageLimit(sqlCountRows, sqlFetchRows, new Object[] {}, pageNo, pageSize,
CONFIG_INFO_TAG_WRAPPER_ROW_MAPPER);
}
@ -1743,9 +1741,7 @@ public class EmbeddedStoragePersistServiceImpl implements PersistService {
PaginationHelper<ConfigInfoAggr> helper = createPaginationHelper();
return helper.fetchPageLimit(sqlCountRows, new Object[] {dataId, group, tenantTmp}, sqlFetchRows,
new Object[] {dataId, group, tenantTmp, (pageNo - 1) * pageSize, pageSize}, pageNo, pageSize,
CONFIG_INFO_AGGR_ROW_MAPPER);
new Object[] {dataId, group, tenantTmp}, pageNo, pageSize, CONFIG_INFO_AGGR_ROW_MAPPER);
}
@Override

View File

@ -1400,8 +1400,8 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
configInfoBetaMapper.findAllConfigInfoBetaForDumpAllFetchRows(startRow, pageSize);
PaginationHelper<ConfigInfoBetaWrapper> helper = createPaginationHelper();
try {
return helper.fetchPageLimit(sqlCountRows, sqlFetchRows, new Object[] {(pageNo - 1) * pageSize, pageSize},
pageNo, pageSize, CONFIG_INFO_BETA_WRAPPER_ROW_MAPPER);
return helper.fetchPageLimit(sqlCountRows, sqlFetchRows, new Object[] {}, pageNo, pageSize,
CONFIG_INFO_BETA_WRAPPER_ROW_MAPPER);
} catch (CannotGetJdbcConnectionException e) {
LogUtil.FATAL_LOG.error("[db-error] " + e.toString(), e);
@ -1417,8 +1417,8 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
String sqlFetchRows = configInfoTagMapper.findAllConfigInfoTagForDumpAllFetchRows(startRow, pageSize);
PaginationHelper<ConfigInfoTagWrapper> helper = createPaginationHelper();
try {
return helper.fetchPageLimit(sqlCountRows, sqlFetchRows, new Object[] {(pageNo - 1) * pageSize, pageSize},
pageNo, pageSize, CONFIG_INFO_TAG_WRAPPER_ROW_MAPPER);
return helper.fetchPageLimit(sqlCountRows, sqlFetchRows, new Object[] {}, pageNo, pageSize,
CONFIG_INFO_TAG_WRAPPER_ROW_MAPPER);
} catch (CannotGetJdbcConnectionException e) {
LogUtil.FATAL_LOG.error("[db-error] " + e.toString(), e);
@ -1760,8 +1760,7 @@ public class ExternalStoragePersistServiceImpl implements PersistService {
PaginationHelper<ConfigInfoAggr> helper = createPaginationHelper();
try {
return helper.fetchPageLimit(sqlCountRows, new Object[] {dataId, group, tenantTmp}, sqlFetchRows,
new Object[] {dataId, group, tenantTmp, (pageNo - 1) * pageSize, pageSize}, pageNo, pageSize,
CONFIG_INFO_AGGR_ROW_MAPPER);
new Object[] {dataId, group, tenantTmp}, pageNo, pageSize, CONFIG_INFO_AGGR_ROW_MAPPER);
} catch (CannotGetJdbcConnectionException e) {
LogUtil.FATAL_LOG.error("[db-error] " + e.toString(), e);

View File

@ -39,7 +39,7 @@ public class ConfigInfoAggrMapperByDerby extends AbstractMapper implements Confi
}
datumString.deleteCharAt(datumString.length() - 1);
return "DELETE FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND datum_id IN ("
+ datumString.toString() + ")";
+ datumString + ")";
}
@Override
@ -71,7 +71,8 @@ public class ConfigInfoAggrMapperByDerby extends AbstractMapper implements Confi
@Override
public String findConfigInfoAggrByPageFetchRows(int startRow, int pageSize) {
return "SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE data_id=? AND "
+ "group_id=? AND tenant_id=? ORDER BY datum_id OFFSET ? ROWS FETCH NEXT ? ROWS ONLY";
+ "group_id=? AND tenant_id=? ORDER BY datum_id OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize
+ " ROWS ONLY";
}
@Override

View File

@ -38,8 +38,8 @@ public class ConfigInfoBetaMapperByDerby extends AbstractMapper implements Confi
@Override
public String findAllConfigInfoBetaForDumpAllFetchRows(int startRow, int pageSize) {
return " SELECT t.id,data_id,group_id,tenant_id,app_name,content,md5,gmt_modified,beta_ips "
+ " FROM ( SELECT id FROM config_info_beta ORDER BY id OFFSET ? ROWS FETCH NEXT ? ROWS ONLY )"
+ " g, config_info_beta t WHERE g.id = t.id ";
+ " FROM ( SELECT id FROM config_info_beta ORDER BY id OFFSET " + startRow + " ROWS FETCH NEXT "
+ pageSize + " ROWS ONLY )" + " g, config_info_beta t WHERE g.id = t.id ";
}
@Override

View File

@ -38,8 +38,8 @@ public class ConfigInfoTagMapperByDerby extends AbstractMapper implements Config
@Override
public String findAllConfigInfoTagForDumpAllFetchRows(int startRow, int pageSize) {
return " SELECT t.id,data_id,group_id,tenant_id,tag_id,app_name,content,md5,gmt_modified "
+ " FROM ( SELECT id FROM config_info_tag ORDER BY id OFFSET ? ROWS FETCH NEXT ? ROWS ONLY ) "
+ " g, config_info_tag t WHERE g.id = t.id ";
+ " FROM ( SELECT id FROM config_info_tag ORDER BY id OFFSET " + startRow + " ROWS FETCH NEXT "
+ pageSize + " ROWS ONLY ) " + " g, config_info_tag t WHERE g.id = t.id ";
}
@Override

View File

@ -92,7 +92,7 @@ public class ConfigInfoTagsRelationMapperByDerby extends AbstractMapper implemen
if (StringUtils.isNotBlank(appName)) {
sql.append(" AND a.app_name=? ");
}
return sql.toString() + " OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY";
return sql + " OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY";
}
@Override
@ -196,7 +196,7 @@ public class ConfigInfoTagsRelationMapperByDerby extends AbstractMapper implemen
if (StringUtils.isNotBlank(appName)) {
sql.append(" AND a.app_name=? ");
}
return sql.toString() + " OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY";
return sql + " OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY";
}
@Override
@ -307,7 +307,7 @@ public class ConfigInfoTagsRelationMapperByDerby extends AbstractMapper implemen
if (StringUtils.isNotBlank(appName)) {
sql.append(" AND a.app_name=? ");
}
return sql.toString() + " OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY";
return sql + " OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY";
}
@Override

View File

@ -39,7 +39,7 @@ public class ConfigInfoAggrMapperByMySql extends AbstractMapper implements Confi
}
datumString.deleteCharAt(datumString.length() - 1);
return "DELETE FROM config_info_aggr WHERE data_id = ? AND group_id = ? AND tenant_id = ? AND datum_id IN ("
+ datumString.toString() + ")";
+ datumString + ")";
}
@Override
@ -71,7 +71,7 @@ public class ConfigInfoAggrMapperByMySql extends AbstractMapper implements Confi
@Override
public String findConfigInfoAggrByPageFetchRows(int startRow, int pageSize) {
return "SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE data_id= ? AND "
+ "group_id= ? AND tenant_id= ? ORDER BY datum_id LIMIT ?,?";
+ "group_id= ? AND tenant_id= ? ORDER BY datum_id LIMIT " + startRow + "," + pageSize;
}
@Override

View File

@ -38,7 +38,7 @@ public class ConfigInfoTagMapperByMySql extends AbstractMapper implements Config
@Override
public String findAllConfigInfoTagForDumpAllFetchRows(int startRow, int pageSize) {
return " SELECT t.id,data_id,group_id,tenant_id,tag_id,app_name,content,md5,gmt_modified "
+ " FROM ( SELECT id FROM config_info_tag ORDER BY id LIMIT ?,? ) "
+ " FROM ( SELECT id FROM config_info_tag ORDER BY id LIMIT " + startRow + "," + pageSize + " ) "
+ "g, config_info_tag t WHERE g.id = t.id ";
}

View File

@ -88,7 +88,7 @@ public class ConfigTagsRelationMapperByMySql extends AbstractMapper implements C
if (StringUtils.isNotBlank(appName)) {
sql.append(" AND a.app_name=? ");
}
return sql.toString() + " LIMIT " + startRow + "," + pageSize;
return sql + " LIMIT " + startRow + "," + pageSize;
}
@Override
@ -189,7 +189,7 @@ public class ConfigTagsRelationMapperByMySql extends AbstractMapper implements C
if (StringUtils.isNotBlank(appName)) {
sql.append(" AND a.app_name=? ");
}
return sql.toString() + " LIMIT " + startRow + "," + pageSize;
return sql + " LIMIT " + startRow + "," + pageSize;
}
@Override
@ -299,7 +299,7 @@ public class ConfigTagsRelationMapperByMySql extends AbstractMapper implements C
if (StringUtils.isNotBlank(appName)) {
sql.append(" AND a.app_name=? ");
}
return sql.toString() + " LIMIT " + startRow + "," + pageSize;
return sql + " LIMIT " + startRow + "," + pageSize;
}
@Override

View File

@ -61,7 +61,7 @@ public interface ConfigInfoAggrMapper extends Mapper {
* Query aggregation config info.
* The default sql:
* SELECT data_id,group_id,tenant_id,datum_id,app_name,content FROM config_info_aggr WHERE data_id=? AND
* group_id=? AND tenant_id=? ORDER BY datum_id LIMIT ?,?
* group_id=? AND tenant_id=? ORDER BY datum_id LIMIT startRow,pageSize
*
* @param startRow The start index.
* @param pageSize The size of page.

View File

@ -37,7 +37,7 @@ public interface ConfigInfoBetaMapper extends Mapper {
* Query all beta config info for dump task.
* The default sql:
* SELECT t.id,data_id,group_id,tenant_id,app_name,content,md5,gmt_modified,beta_ips,encrypted_data_key
* FROM ( SELECT id FROM config_info_beta ORDER BY id LIMIT ?,? ) g, config_info_beta t WHERE g.id = t.id
* FROM ( SELECT id FROM config_info_beta ORDER BY id LIMIT startRow,pageSize ) g, config_info_beta t WHERE g.id = t.id
*
* @param startRow The start index.
* @param pageSize The size of page.

View File

@ -38,7 +38,7 @@ public interface ConfigInfoTagMapper extends Mapper {
* Query all tag config info for dump task.
* The default sql:
* SELECT t.id,data_id,group_id,tenant_id,tag_id,app_name,content,md5,gmt_modified
* FROM ( SELECT id FROM config_info_tag ORDER BY id LIMIT ?,? ) g,
* FROM ( SELECT id FROM config_info_tag ORDER BY id LIMIT startRow,pageSize ) g,
* config_info_tag t WHERE g.id = t.id
*
* @param startRow The start index.