oracle in exists performance选择性

oracle 数据库中既然存在着exists 与 in,肯定有他们各自的工作原理以及各自的优势。

   in,exists,join都能利用索引,但是工作原理不同。

1、 当call_records表中数据少而customers中的数据多时,此时选用in的性能要优于exists。因为用in时,驱动表为call_records,再用主表查询出来的记录遍历循环子查询记录。

2、当customers中的记录少而call_records的记录多时,此时选用exists的性能要优于customers,因为用exists时,驱动表为cuntomers,用子查询记录中的每一条记录去遍历“主查询”的每一条记录。

猜你喜欢

转载自ilovejoe.iteye.com/blog/2119960
今日推荐