以前运行速度还挺好的,这次把试图改了一下,性能就出现问题了,硬是不知道该怎么处理了,待我细细道来。oracle 9i数据库有试图 v 和表 t情况如下:直接查表:select id from t where id<5;
这样查起来很快。返回结果为:1,2,3,4接下来查试图:select * from v where tid in(1,2,3,4);
这样查起来很快。但是换成下面查询就很慢很慢了。
select * from v where tid in(select id from t where id<5);一直不解为什么会这样,哪位帮忙解决下,小弟不胜感激。
这样查起来很快。返回结果为:1,2,3,4接下来查试图:select * from v where tid in(1,2,3,4);
这样查起来很快。但是换成下面查询就很慢很慢了。
select * from v where tid in(select id from t where id<5);一直不解为什么会这样,哪位帮忙解决下,小弟不胜感激。
解决方案 »
- 有关oracle中表分区维护的问题,求高手解答
- oracle 10 data guard问题求助?
- ASP.net2.0 + Oracle 9i开发网站,使用什么数据库对象合适?
- 一个安装的问题,在线等
- ORACLA数据库里如果要从一个表中查询出某些为空的字段的值,应该怎么写SQL啊
- 如何获得oracle的一个库的所有表名
- 又一个sql语句的奇怪现象
- !急急急急急急急!!!!!求救ORACLE工程师,无法起动数据库,ORA-00600错误!!!!!
- dual 是个什么表
- impdp从linux网络导出导入数据库到window下全是错误... 求大神
- 请问oracle中如何将每条大字段Clob保存为单个xml文档
- 关于建分区索引的问题哦 如果分区很多怎么办?
--v,t表都建立索引,應不會很慢的
select * from v where exists(select 1 from t where t.id=v.tid and t.id<5);
select id from t where b in(1);返回结果为:1,2,3,4我试过以下几种查询方式:
select * from v where tid in(select id from t where b in(1));select * from v where tid in(select id from t where b=1);select * from v where exists (select 'X' from t where b in(1) and b.id=a.tid);select * from v where exists (select 'X' from t where b=1 and b.id=a.tid);这四种查询结果是一样的,很慢很慢。
select * from v where tid in(select /*+no_unnest*/ id from t where id<5);
创建视图的时候,视图里面已经写了一些SQL调优策略。
create view v_a
as
select t.a,t.b,t.c from t_a t;create view v_b
as
select a.*,(select tc from t_c where ta=a.a) tc from v_a a;结果查
select * from v_b where a in(select a from t_a where a in(1,2,3,4));这样就很慢select * from v_b where a in(1,2,3,4);这样很快select * from v_a where a in(select a from t_a where a in(1,2,3,4));这样也很快。还不知道为什么会这样。