minus/not in/not exists的原理和效率

http://www.itpub.net/viewthread.php?tid=984425&extra=&page=3

minus:

[
CODE:
Select *
From gal_voucher_item item
Where item_iid In (Select item_iid
                                  From gal_voucher_item
                                  Minus
                                 Select item_iid From gal_voucher_item_detail);


时间:4.438/4.39 s

not in:

Select *
From gal_voucher_item  item
Where Not Exists (Select /*+ hash_aj */ 1 From gal_voucher_item_detail detail Where item.item_iid = detail.item_iid);

时间:比上面MIUNUS快多了。

not in:

CODE:
Select * From gal_voucher_item Where item_iid Not In (Select item_iid From gal_voucher_item_detail);


时间:没跑出来

not exists:

CODE:
Select *
From gal_voucher_item item
Where Not Exists (Select 1 From gal_voucher_item_detail detail Where item.item_iid = detail.item_iid);


时间:没跑出来

你可能感兴趣的:(PHP,.net)