
一共加了三条数据
insert into pl_org_region(parent_id,region_sn,region_name,comments) values (0,'001','北京大区','无')insert into pl_org_region(parent_id,region_sn,region_name,comments) values (0,'002','西南大区','无')
insert into pl_store (store_sn,region_id,region_name) values ('P001',6,'北京大区')
查询语句改成:
SELECTp.region_id,
COUNT(p.region_id) AS cnt,
r.*
FROM
pl_org_region r
LEFT JOIN pl_store p ON r.region_id = p.region_id
GROUP BY
p.region_id
查询结果:
mysql查询树状菜单有多少层java版的实际例子。类同你说的情况
private void findChildList(AssetType parent,List<AssetType>list){
String hql = "from AssetType a where a.parentAssetType.assetTypeId=? ORDER BY a.sort,a.assetTypeName asc"
List<AssetType>childList = this.assetTypeDao
.getEntityManager()
.createQuery(hql)
.setParameter(1, parent.getAssetTypeId())
.getResultList()
int size = childList.size()
if(size>0){
for (int i = 0i <sizei++) {
AssetType assetType = childList.get(i)
List<AssetType>childs = assetType.getChildAssetType()
if(childs.size()>0){
list.addAll(childs)
this.findChildList(assetType, list)//递归查询节点的子节点
}
}
}
}
IO的统计公式如下:Key_reads * 2 + Key_writes * 2 + Key_read_requests + Innodb_data_reads + Innodb_data_writes + Innodb_dblwr_writes + Innodb_log_writes
key_reads 和 key_writes都乘以2的原因是因为如果从磁盘中读或写索引块之后会再去磁盘读或写数据块,所以就会有至少两倍的IO请求.
事务数总量为 com_commit+com_rollback
query数通过 com_select获取
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)