SELECT DISTINCT or array_unique?

What do you think faster?

  • SELECT DISTINCT (user_id) FROM myTable -fetch-> $ myArray

or

  • SELECT user_id FROM myTable -fetch-> $ myArray and then: $ myArray = array_unique ($ myArray)

* user_id - FINITE-FOREIGN KEYBOARD *

+4
source share
1 answer

For speed and memory efficiency, you want to return the minimum amount from the database without putting unnecessary rows for processing / memory efficiency. Therefore, the best choice is excellent in this case.

+6
source

All Articles