现在有cust,serv两张表,现在必须要关联两张表进行count,数据量量张表都在50W左右,现在查询要6秒左右,有什么好的优化方法吗,sql语句如下:
select /*+ index_ffs(cust) */ count(distinct a.cust_no) as record_count From cust a, serv b
Where a.cust_type =1 And a.vip_type >=-1
And a.mature_grade >=1 And a.state <>'70X' and a.cust_id = b.cust_id And (a.organ_code like '%@@%' )
select /*+ index_ffs(cust) */ count(distinct a.cust_no) as record_count From cust a, serv b
Where a.cust_type =1 And a.vip_type >=-1
And a.mature_grade >=1 And a.state <>'70X' and a.cust_id = b.cust_id And (a.organ_code like '%@@%' )
解决方案 »
- 求一个DBMS_LOCK简单例子
- Oracle 存储过程 未找到要求的From关键字错误
- 利用oracle高级复制功能实现数据同步的问题
- 急急急**为何我的oracle8.1.7.0.0企业版仍然无法建立分区表,请高手指教。*****
- 执行access的错误,为什么,还需要什么吗?
- 给电信作一个系统,每天要生成几万条记录,该怎么存储?
- 新年好啊!请教各位高手一个问题?
- 在oracle8.1.7下用exp卸oracle8.1.5的数据库不可行,系统提示版本不支持,我该怎么办?
- 如何在PowerDesigner中翻转生成PDM图时把Name属性变成Oracle注释
- Oracle的sql developer里面脚本输出部分出现乱码
- 能否在TOAD中直接减小TEMP临时表空间文件的大小 达到释放磁盘空间的目的?
- dbms_random.seed到底是用来干吗的啊?
, distinct 是否可以去掉? 还有 <> 和 %%都会引起表扫描.
b表b.cust_id字段一定要加索引即可,
select /*+ index_ffs(cust) */ count(distinct a.cust_no) as record_count From cust a, serv b
Where a.cust_type =1 And a.vip_type >=-1
And a.mature_grade >=1 And a.state <>'70X' and a.cust_id = b.cust_id And (a.organ_code like '%@@%' )改成
select /*+ index_ffs(cust) */ count(distinct a.cust_no) as record_count From cust a, serv b
Where a.cust_id = b.cust_id and a.organ_code like '%@@%' and (a.state >'70X' or a.state<'70X')
and a.mature_grade >=1 And a.vip_type >=-1 a.cust_type =1