Have you ever written a database call that went something like... select * from posts where id=3;? We probably all have, but it's bad for several reasons. Four of them, according to a programmer that goes by pizza_milkshake.
To database administrators and advanced programmers, this may not come as news. Even many seasoned coders could use a reminder not to be lazy.
pizza_milkshake's Four Reasons Not to Select All
- If you include the field names, your code is self-documenting
- When a field name changes, you want to know with a query error, not later
- Asking for more than you need is just wasting resources
- Without naming the fields, you can't be certain of the order you'll receive them
I hope these reasons are good enough to encourage your next query to not start select *.
See also: