寻求帮助--优化SQL

patrick1683 2015-05-14 02:29:28
select /* 70674:200 */
m.id,
substr(m.flags, 2, 1) deleted_flag,
substr(m.flags, 1, 1) read_flag,
p.id mail_to_userid,
m.subject subject,
substr(m.flags, 1, 1) read,
m.received_on received_on,
m.message_body message_desc,
substr(m.flags, 2, 1) deleted
from fgt_mail_header m
inner join cmt_person p on m.mail_to = p.id
inner join fgt_ext_notify_event e on m.event_id = e.id
inner join fgt_memo_mail_body b on m.id = b.owner_id
where m.id = m.id
and p.locale_id = e.locale_id
and m.mail_to = lower(:1)
and substr(m.flags, 2, 1) = :2
ORDER BY 6, 7 desc

cmt_person有50万条记录,fgt_mail_header有16万条记录,执行时间为620毫秒; 希望能有优化的方法,请大俠指点优化方法。
...全文
213 2 打赏 收藏 举报
写回复
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
mayanzs 2015-05-25
  • 打赏
  • 举报
回复
关键是索引,检查一下所需关联的关键字段上索引是否齐全,另fgt_mail_header表上建立substr(m.flags, 2, 1)的索引试试
bfc99 2015-05-14
  • 打赏
  • 举报
回复
提供一下执行计划。
相关推荐
发帖
Oracle 高级技术

3477

社区成员

Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
帖子事件
创建了帖子
2015-05-14 02:29
社区公告
暂无公告