急!请帮忙指点一个SQL语句的优化问题

UChuaihuai 2003-10-21 10:05:35
select
distinct *
from
person,addr,contract
where
lower(per_name) like '%john%' and
con_type = 'I' and
con_tin = per_ssn and
con_number = add_num and
(add_type = '01' or add_address_type = '02' or add_type = '29')

三个表均有300000条左右数据,其中add_type共有10种,con_type有两种。结果约有2000条数据,所有查询子段均建立了索引,但是查询速度非常慢。请问各位有没有办法优化。先谢了!
Execution plan:

OPERATION OPTIONS
------------------------------ --------
SELECT STATEMENT
SORT UNIQUE
MERGE JOIN
SORT JOIN
HASH JOIN
TABLE ACCESS FULL
TABLE ACCESS FULL
SORT JOIN
TABLE ACCESS FULL
...全文
47 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
LGQDUCKY 2003-10-21
  • 打赏
  • 举报
回复
lower(per_name) like '%john%' 这样是用不上索引的
把这个优化了。。
hdkkk 2003-10-21
  • 打赏
  • 举报
回复
Execution plan显示没有用到所引,使用hint /*+index()*/
JasLi 2003-10-21
  • 打赏
  • 举报
回复
看一下索引的用法,印象里:索引的顺序和WHERE字句中引用字段的顺序要一致;如果字段本身取值只有几个(如2个)没必要建索引;使用函数通常用不到索引。
hope it's helpful !
beckhambobo 2003-10-21
  • 打赏
  • 举报
回复
语句不能最终解决性能问题,根本在于表结构设计是否合理,大表,小表等
vrv0129 2003-10-21
  • 打赏
  • 举报
回复
group by 比distinct的速度开多了
vrv0129 2003-10-21
  • 打赏
  • 举报
回复
select
*
from
person,addr,contract
where
lower(per_name) like '%john%' and
con_type = 'I' and
con_tin = per_ssn and
con_number = add_num and
(add_type = '01' or add_address_type = '02' or add_type = '29')
group by person.OPERATION
tsj68 2003-10-21
  • 打赏
  • 举报
回复
不知3个表的表结构如何,可以贴出来看一下.
pengdali 2003-10-21
  • 打赏
  • 举报
回复
select
distinct *
from
person,addr,contract
where
instr(lower(per_name),'john')>0 and
con_type = 'I' and
con_tin = per_ssn and
con_number = add_num and
(add_type in ('01','29') or add_address_type = '02')

17,082

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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