This is an interesting question. There are a lot of arguments for using the second method -- putting the values in the array.
Using a temporary table is not an unreasonable option, but it adds significant complexity to the application. It adds reading and writing overhead to the database. The application has to create the table and load it (the database will take care of removing it).
If you do think that you need this option, be sure that the phone number is the primary key in the table. That is optimal for performance.
Using IN
-- especially in MySQL -- is a reasonable option. MySQL orders constant IN
lists and uses a binary search for matching values. This is going to be most beneficial for a full-table scan. With that large a list, a full table scan is likely to be the most efficient method.
Personally, I would start with the IN
list. Generating a query with an IN
list with 1,000 elements is the same code complexity as a list with 3 elements. If that is not meeting your needs, then try out the performance using a temporary table. If it works much better, then go for that approach.