我在NOT IN語句中有超過400 000個id。它會執行還是不執行?MySQL查詢長度
$query = "
SELECT
*
FROM
table_name
WHERE
my_field_id NOT IN(
34535345,3453451234,234242345,3465465,12234234,23435465,122343,345435,3453454,
34535345,3453451234,234242345,3465465,12234234,23435465,122343,345435,3453454,
34535345,3453451234,234242345,3465465,12234234,23435465,122343,345435,3453454,
34535345,3453451234,234242345,3465465,12234234,23435465,122343,345435,3453454,
34535345,3453451234,234242345,3465465,12234234,23435465,122343,345435,3453454,
34535345,3453451234,234242345,3465465,12234234,23435465,122343,345435,3453454
)
";
這些ID從哪裏來? – xdazz
@miqdad阿里你能告訴我這個查詢的執行時間,似乎在我看來:) – Rinzler
@Rinzler:這個查詢很可能產生表全面掃描。所以執行時間取決於表的大小 – zerkms