Commit 6e870159 authored by 郝彦辉's avatar 郝彦辉

2020.05.08学磊反馈说max(id)及insert慢,减少批量提交的数量

parent 2d08fd19
......@@ -44,7 +44,9 @@ public class ConstantBlackGrey {
"WHERE c.id IN (##IN_USER_ID##);";
//分页查询结果表黑名单
public static String BL_QUERY_BLACKLIST_RESULT_MAX_ID = " SELECT max(id) as 'maxId' FROM black_grey_list_result r WHERE r.black_type='1';";
//public static String BL_QUERY_BLACKLIST_RESULT_MAX_ID = " SELECT max(id) as 'maxId' FROM black_grey_list_result r WHERE r.black_type='1';";
//2020.05.08 学磊反馈说max(id)慢
public static String BL_QUERY_BLACKLIST_RESULT_MAX_ID = " SELECT id as 'maxId' FROM black_grey_list_result r WHERE r.black_type='1' order by id desc limit 1;";
public static String BL_QUERY_BLACKLIST_RESULT_BY_LIMIT_ID = " SELECT ##r.*## " +
" FROM black_grey_list_result r " +
" WHERE r.black_type='1' AND id >? AND id<=?; ";
......
......@@ -600,7 +600,7 @@ public class BlackGreyListServiceImpl implements IBlackGreyListService {
}
inCount++;
if(inCount>=1000){
if(inCount>=500){ //500条查一次
try{
String sql = ConstantBlackGrey.SQL.XYQBUSER_QUERY_VCC_15DAY;
sql = sql.replace("##IN_USER_ID##",userIds.toString());
......
......@@ -62,7 +62,9 @@ public class JdbcExecuters {
ps.addBatch();
atomicInteger.getAndIncrement();
if (i > 0 && i % 5000 == 0) {
//if (i > 0 && i % 5000 == 0) {
//2020.05.08 学磊说insert太慢,减小提交数
if (i > 0 && i % 500 == 0) {
ps.executeBatch();
conn.commit();
ps.clearBatch();
......@@ -196,7 +198,9 @@ public class JdbcExecuters {
ps.addBatch();
atomicInteger.getAndIncrement();
if (i > 0 && i % 1000 == 0) {
//if (i > 0 && i % 1000 == 0) {
//2020.05.08 学磊说insert太慢,减小提交数
if (i > 0 && i % 500 == 0) {
ps.executeBatch();
conn.commit();
ps.clearBatch();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment