帮忙优化下

liyufu86 2009-04-10 05:12:23
前人写的代码
发现执行起来很慢

高人看看怎么优化

select count( distinct a.id ) from OrderProductItem a where ( a.stauts= 2 and a.orgId= 10000 ) or (a.id in (select a.parentid from a where a.stauts= 0 and a.stauts_deliver= 22 group by a.parentid ))

十分感谢

不知道为什么很慢,
...全文
94 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
you_tube 2009-04-10
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 liyufu86 的回复:]
谢谢楼上的2位,为什么我的那个查询很慢呢
[/Quote]


select count( distinct a.id ) from OrderProductItem a where ( a.stauts= 2 and a.orgId= 10000 ) or (a.id in (select a.parentid from a where a.stauts= 0 and a.stauts_deliver= 22 group by a.parentid ))

in这个相当再查询一遍



等不到来世 2009-04-10
  • 打赏
  • 举报
回复
你那个查询应该会运行时报错。
等不到来世 2009-04-10
  • 打赏
  • 举报
回复
select count(distinct id)
from
(
select id from OrderProductItem where stauts= 2 and orgId= 10000
union all
select a.id
from OrderProductItem a join OrderProductItem b
on a.id=b.parentid
where b.stauts=0 and b.stauts_deliver= 22
) t
liyufu86 2009-04-10
  • 打赏
  • 举报
回复
谢谢楼上的2位,为什么我的那个查询很慢呢
moonshineidolon 2009-04-10
  • 打赏
  • 举报
回复
select count( distinct a.id )

from OrderProductItem a where

( a.stauts= 2 and a.orgId= 10000 ) or

(

a.id in (


select a.parentid from a where a.stauts= 0 and a.stauts_deliver= 22


)

)
pt1314917 2009-04-10
  • 打赏
  • 举报
回复

--try:
select count( distinct a.id ) from OrderProductItem a ,a t
where (a.stauts= 2 and a.orgId= 10000 ) or (a.id=t.parentid and t.stauts= 0 and t.stauts_deliver= 22 )
v1.5.2 Build 1 版汉化说明 汉化人:王锦阳 汉化语言:简体中文 汉化版本:1.5.2 Build 1 EasyUI版本:1.5.2 汉化时间:2017年06月27日 个人博客:http://blog.sina.com.cn/richie696 好吧,这次更新迟了,因为工作实在太忙,加上最近在忙着买车的事情,所以已经顾不过来了,今天上easyui官网看已经发布1.5.2了,查了一下发现好久之前就更新了,好在主要是优化和BUG修复,没有什么新内容的加入,所以应该不会妨碍大家使用,另外由于官方会不定期的更新官方的文档,更新也不会通知我,所以我制作API的时候也只能根据我所在时间点的官方文档作为翻译基础,而文档发布之后更新的内容自然不会出现在中文API当中,所以这就需要大家的帮忙和反馈了,反馈方式有2种: 1.我的博客文章下直接回复; 2.加入Easy UI的使用交流群:189263358(本群欢迎那些愿意分享和帮助别人的人,如果只是那种一味只知道求帮助而从不帮助别人的人请勿加群,否则加了也会被踢掉,谢谢配合。) 反馈后我会将新内容加入,我不可能每次更新文档都将中文API和英文官网上的文档做一次1:1的校验,这样工作量太大,我也没那么多时间,所以感谢大家来一起帮忙完善! jQuery EasyUI 1.5.2 版本更新内容 Bug(修复) • form:修复在调用“reset”方法的时候会导致input输入框初始值消失的BUG; • textbox:修复在调用“destroy”方法的时候无法清除字段标签的BUG; • datagrid:修复在不存在的行上调用“selectRow”方法的时候会导致记录无效行信息的BUG。 Improvement(改进) • datagrid:ctrl键选择支持Mac键盘; • datagrid:新增“scrollOnSelect”属性,可以让用户确定是否在选择行时自动滚动到对应行所在的位置; • combotree:添加“textField”属性; • combotreegrid:添加“textField”属性; • pagination:添加“showPageInfo”属性; • panel:添加“halign”和“titleDirection”属性,以允许用户自定义面板标题文字的对齐方式; • accordion:添加“halign”属性,以允许用户构建水平方向的分类标签; • tagbox:添加“required”属性,以允许用户将其用于验证指定值是否为空(译者注:该属性自validatebox继承而来,1.5.2版之前也有该属性只是设置以后无效)。

22,211

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧