标签:很多 get table sele 情况 情况下 and list 有一个
登录类,发现很多如下代码:
====================================================================================
hql = " from SafetyOperationAdvise where (checker=‘" + checker + "‘ or checker in ("+hqlAssigner.toString()+"63)"+") ) and status in (‘101‘,‘110‘) ";
list = baseDao.findByHQL(hql);
pair[165] = list.size();
====================================================================================
这里很多审核、收文等一些系列东西,基本上一种审核最少要查询一张表。当数据越来越庞大,上面这种代码就会非常影响效率,这里修改为如下方式:
====================================================================================
hql = "select count(keyId) from SafetyOperationAdvise where (checker=‘" + checker + "‘ or checker in ("+hqlAssigner.toString()+"63)"+") ) and status in (‘101‘,‘110‘) ";
list = baseDao.findByHQL(hql);
pair[165] = Integer.parseInt(list.get(0).toString());
====================================================================================
select count() , select count(1)和select count(keyId)优化如何选择
标签:很多 get table sele 情况 情况下 and list 有一个
原文地址:https://www.cnblogs.com/kaspar/p/13395048.html