I have more than 400 000 id’s in NOT IN statement. Whether it will execute or not ?
$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
)
";
Yes it will (you could try that yourself without asking here actually). There is no reasonable limit for sql query string.
But you should keep in mind the more ids you add – the slower the query will be
PS: the only mysql setting you may be interested in is
max_allowed_packet. From what I remember it is the only parameter that could bring some issues on extra-large queries