一句语句
select * from tab1 a,tab2 b where a.cino=b.cino and b.v_month='201001'
tab1表的主键为cino tab2(分区表)的主键为cino,v_month
数据量都非常大 都有几百万条以上记录 以上语句分析后没有用到索引
如加一约束如 and a.cino='050800006458541'
如下面
select * from tab1 a,tab2 b where a.cino=b.cino and b.v_month='201001' and a.cino='050800006458541'
两个索引都生效 请教是何原因?如何解决 谢谢
select * from tab1 a,tab2 b where a.cino=b.cino and b.v_month='201001'
tab1表的主键为cino tab2(分区表)的主键为cino,v_month
数据量都非常大 都有几百万条以上记录 以上语句分析后没有用到索引
如加一约束如 and a.cino='050800006458541'
如下面
select * from tab1 a,tab2 b where a.cino=b.cino and b.v_month='201001' and a.cino='050800006458541'
两个索引都生效 请教是何原因?如何解决 谢谢
你可以给v_month 单独建个索引
但在select * from tab1 a,tab2 b where a.cino=b.cino and b.v_month='201001'
条件应该都有
你的分区表是怎么建的 以日期还是什么 查询的时候的要指定分区表 速率快些
加强制
/*+ index(tablename indexname)*/