oracle大数据量优化——>在线等

yang448246711 2010-07-29 10:49:17
select count(1) from t_customer where orgid='3' and custbirthday<>to_date('1900-10-10','yyyy-mm-dd') and to_char(custbirthday,'mm')=to_char(sysdate,'mm');

此查询请问有没有哪位大大能给我写个优化版本,数据量450W左右,而且数据经常更新,结果常变!
...全文
107 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yang448246711 2010-07-29
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 minitoy 的回复:]
取的是当前月份最后一天的23:59:59,是先取下个月第一天的0:0:0,再减去1秒
[/Quote]

哦好的,我试试看~~
minitoy 2010-07-29
  • 打赏
  • 举报
回复
取的是当前月份最后一天的23:59:59,是先取下个月第一天的0:0:0,再减去1秒
minitoy 2010-07-29
  • 打赏
  • 举报
回复
减去1秒
yang448246711 2010-07-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 minitoy 的回复:]
select count(1) from t_customer where orgid='3' and (custbirthday>to_date('1900-10-10','yyyy-mm-dd')or custbirthday>to_date('1900-10-10','yyyy-mm-dd'))
and custbirthday between trunc(sysdate,'mm') a……
[/Quote]

请问下后面加上这个有什么意思?-1/24/60/60
minitoy 2010-07-29
  • 打赏
  • 举报
回复
orgid上如果有索引就不用改了。
如果是custbirthday 有所依就改成上面的形式。
minitoy 2010-07-29
  • 打赏
  • 举报
回复
select count(1) from t_customer where orgid='3' and (custbirthday>to_date('1900-10-10','yyyy-mm-dd')or custbirthday>to_date('1900-10-10','yyyy-mm-dd'))
and custbirthday between trunc(sysdate,'mm') and add_months(trunc(SYSDATE,'mm'),1)-1/24/60/60
suiziguo 2010-07-29
  • 打赏
  • 举报
回复
表结构,索引情况?

是否分区?

17,382

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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