情况这样2张表A表 10W+的数据 24个字段, 需要用到 url area 这2个字段 这2个都加了索引B表 40W+的数据 4个字段, 需要用到 url name 这2个字段 都加索引B表的 name 有43种 随机分摊到每个URL,每个name对应的url的数量有数千到2W不等,并且存在重复的可能,所以还需要祛重
假设abc这个name对应100个URL的量,但实际祛重后只有50条urlselect a.area,count(distinct a.url) from tableA a ,tableB bwhere a.url=b.urland b.name="adasd"group by a.areaorder by count(distinct a.url) desc目的是循环B表的name 把43个name 都按这个SQL算一遍
现在的情况是 SQL运行速度狂慢 1个小时只能跑2个name的计算求高速的.............
假设abc这个name对应100个URL的量,但实际祛重后只有50条urlselect a.area,count(distinct a.url) from tableA a ,tableB bwhere a.url=b.urland b.name="adasd"group by a.areaorder by count(distinct a.url) desc目的是循环B表的name 把43个name 都按这个SQL算一遍
现在的情况是 SQL运行速度狂慢 1个小时只能跑2个name的计算求高速的.............
解决方案 »
- PostgreSql 用Devart链接字符串问题
- 请教一个mysql语句,limit的用法
- 在phpmyadmin不小心删了一个库,有办法恢复吗??急!!
- 请教:乱序操作MySQL性能下降很快,不知是何原因?
- [mysql]把一张表的n~n+10条记录(按a字段从高到低排序)的b字段值为1的改成0
- 为什么Mysql安装启动后数据库无法建表?
- 请问大家关于MySql数据备份的问题???(解决给分)
- 好消息,最新版Mysql已经支持简单的事务处理了,免费而精美的午餐就要来了!
- sqlite四个表联合查询
- SQL语句执行顺序的疑问
- MYSQL如何设置大小写敏感
- Debian 5.0下mysql 修改数据存储路径
1 、simole 、b 、ref 、B表url,B表name 、B表name 、768 、const 、32184 、using where;using temporary 、using filesort
1 、simole 、a 、ref 、A表url,A表area 、A表url 、768 、裤.b.url 、1 、using where
需要以下索引
B表复合索引(name,url)
A表复合索引(url,area)
select A.area, count(B.url) from A, (select distinct url from B where name='adasd') as B group by A.area order by B.url desc