有两个表
user_notice(nid number primary key,user_id number,notice_info varchar2(10));
subscription(subscriber number,subscribed number,primary key(subscriber,subscribed ))我在user_notice.user_id 上创建了一个索引
现在我要查
select * from user_notice s where exists (select null from subscription c where c.subscriber=1715 and s.user_id = c.subscribed )
为什么他对user_notice要全表扫描,而不走索引?
select * from user_notice s where exists (select null from subscription c where s.user_id = c.subscribed and c.subscriber=1715) 也是一样
user_notice(nid number primary key,user_id number,notice_info varchar2(10));
subscription(subscriber number,subscribed number,primary key(subscriber,subscribed ))我在user_notice.user_id 上创建了一个索引
现在我要查
select * from user_notice s where exists (select null from subscription c where c.subscriber=1715 and s.user_id = c.subscribed )
为什么他对user_notice要全表扫描,而不走索引?
select * from user_notice s where exists (select null from subscription c where s.user_id = c.subscribed and c.subscriber=1715) 也是一样
FILTER
TABLE ACCESS FULL WestTo USER_NOTICE
INDEX UNIQUE SCAN WestTo SYS_C002420
要是还不行,我也不知道了,我觉得应该走索引