Easy question: SELECT * more expensive than selecting some fields, it can even be dramatic. Less data, no access to the table if all fields are in the index. Lack of marshalling from the value of the database field for a programming language variable.
Nested subqueries and joints are eligible.
SELECT * FROM customers where customers_id NOT IN (SELECT customers_id FROM orders)
can be rewritten as:
SELECT * FROM customers c WHERE NOT EXISTS(SELECT * FROM orders o WHERE o.customers_id = c.customers_id)
MySQL says that it can better optimize EXISTS, since recursively optimized choices now have information about c.customers_id.
Although it will be best to JOIN @StilesCrisis, although I doubt it is correct. (I didn't drink my first cup of coffee during the day, though.)
BTW. EXISTS(SELECT * does not actually reserve space for all fields, and everything is in order.
source share