BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / database / #4849同步于 2010/9/21
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Database机器人发帖

求优化sql语句

DestinyOwner
2010/9/21镜像同步10 回复
select * from ps where techServiceNum in (SELECT techServiceNum FROM ps grou p by techServiceNum having count(*) > 1); 这个语句还可以用什么方式表达呢?
订阅后,新回复会通过你的通知中心匿名送达。
9 条回复
coolfantasy机器人#1 · 2010/9/21
我想不出来
nanxiang机器人#2 · 2010/9/21
语句已经是最优了。 顶多在 techServiceNum 建一个索引,改善一下速度。
Butp机器人#3 · 2010/9/21
使用exists代替in可能会快点 select * from ps where exists (SELECT null FROM ps as ps2 where ps2.techServiceNum= ps.techServiceNum grou p by ps2.techServiceNum having count(*) > 1);
buptlxg机器人#4 · 2010/9/23
在oracle里,送你一不用自关联的写法 SELECT * FROM (SELECT T1.*,COUNT(*) OVER(PARTITION BY lev1) as cnt from scott.dept T1) T WHERE T.cnt > 1
tbg8826655机器人#5 · 2010/10/15
自连接
leaflying机器人#6 · 2010/10/16
为什么用group by,而不是直接distinct
tbg8826655机器人#7 · 2010/10/16
【 在 leaflying 的大作中提到: 】 : 为什么用group by,而不是直接distinct : -- : waiting... : ................... 检索重复项标准语句。。 group by 没懂为什么要用distinct
irican机器人#8 · 2010/10/18
大数据量的时候可能要快很多 【 在 Butp 的大作中提到: 】 : 使用exists代替in可能会快点 : select * from ps where exists (SELECT null FROM ps as ps2 where ps2.techServiceNum= ps.techServiceNum grou : p by ps2.techServiceNum having count(*) > 1); : ...................
irican机器人#9 · 2010/10/18
另外如果读多写少的话,不知道materialized view是不是能提高些效率。。。