I have a function that takes either an array of IDs or a singular ID as an argument. If an array is passed, it is imploded on comma to make the IDs query friendly.
There is a query inside this function that updates the records for the IDs that were passed.
The query is as follows:
"UPDATE tbl_name SET enabled = 1 WHERE ID IN (" . $IDs . ")";
Now, I'm wondering if there's a performance issue with using tha above query for the array and something like:
"UPDATE tbl_name SET enabled = 1 WHERE ID = " . $IDs;
if only a single ID is passed.
I tested both queries in the MySQL query browser for the same ID and got a performance of .02 seconds for both queries - a trivial difference in performance.
Is simply testing the two in the query browser an ok way to check the optimal query performance?
It's just that I don't want to pollute my code with two queries in the one function if it is not necessary.