记一次SQL优化

数据库:ORACLE

工具:PL SQL DEVELOPERS

现象:查询和导出一个小时不带停的

优化方法:

1、优化关联表字段

原:join A

改:join (select cola,colb from A) A

2、关联表去重

原:join (select cola,colb from A) A

改:join (select distinct cola,colb from A) A

3、先转换再使用

原:

select

regexp_substr(to_char(clobcol),'\"name\":\"jack\"',1,1,'i'),

regexp_substr(to_char(clobcol),'\"gender\":\"男\"',1,1,'i'),

改:from (select to_char(clobcol) from A) A

4、子查询优化

原:select (select …) A,(select…)B…

改:select A,B… from (…)

5、distinct和group by

你可能感兴趣的:(sql,oracle,数据库)