0
Suppose I have a table with 100,000 records, which in this example I will call dictionary, and will have a LIMIT
of 1000 results.
SELECT FROM * dicionario
Let’s say that hypothetically I have already made a query and in this query I took the ID of 1000 results and turned into an array.
Taking into account the performance at the time of consultation, it would be more worth redoing the SELECT
using the same condition in WHERE
, or it would be more worthwhile to do the SELECT
using in the WHERE
the id that composes the array, something like:
$arrayId = 1, 20, 101, 345, 800, .... 7001.
SELECT FROM * dicionario WHERE id IN (". $arrayId .")
My doubt arose based on my current situation, where in fact I already have an array with the ID, because in this way I believe that it would spare me some SELECT, but I was worried about the performance and use of resources, such as memory.
I agree with the reply of @msb but then I ask you: Is there really a need to redo the query? Suddenly the solution is to change the query a little and do it only once.
– Edson Horacio Junior