mysql 单表记录效率_mysql数据库如何提高查询效率,单表记录数有几亿条,指定索引效率还是很慢...

SELECTa1.juanhao,a1.c1,a2.c2,a3.c3,a4.c4,a5.c5,a6.c6FROM"+"(selectjuanhao,COUNT(CASEWHENzigao="+zg1+"THEN1END)ASc1FROMtable1FORCEINDEX(zg)GROUPBYjuanhao)ASa1,"+"(selectju...

SELECT a1.juanhao,a1.c1,a2.c2,a3.c3,a4.c4,a5.c5,a6.c6 FROM"+"(select juanhao,COUNT(CASE WHEN zigao="+zg1+" THEN 1 END) AS c1 FROM table1 FORCE INDEX(zg) GROUP BY juanhao) AS a1,"+"(select juanhao,COUNT(CASE WHEN zigao="+zg2+" THEN 1 END) AS c2 FROM table1 FORCE INDEX(zg) GROUP BY juanhao) AS a2,"+"(select juanhao,COUNT(CASE WHEN zigao="+zg3+" THEN 1 END) AS c3 FROM table1 FORCE INDEX(zg) GROUP BY juanhao) AS a3,"+"(select juanhao,COUNT(CASE WHEN zigao="+zg4+" THEN 1 END) AS c4 FROM table1 FORCE INDEX(zg) GROUP BY juanhao) AS a4,"+"(select juanhao,COUNT(CASE WHEN zigao="+zg5+" THEN 1 END) AS c5 FROM table1 FORCE INDEX(zg) GROUP BY juanhao) AS a5,"+"(select juanhao,COUNT(CASE WHEN zigao="+zg6+" THEN 1 END) AS c6 FROM table1 FORCE INDEX(zg) GROUP BY juanhao) AS a6 "+"where a1.juanhao=a2.juanhao AND a2.juanhao=a3.juanhao AND a3.juanhao=a4.juanhao AND a4.juanhao=a5.juanhao AND a5.juanhao=a6.juanhao

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值