|
Posted by Michael Fesser on 08/03/07 11:06
..oO(David Gillen)
>If I want all column in a table though surely SELECT * is better.
Depends.
>In fact, performance on SELECT * is better than "SELECT field1, field2, field3,
>field4, field5, field6, field7, field8" because mysql doesn't have to go
>looking for the specific fields you've requested
Did you test that or is it just a wild guess?
>but just returns you
>everything and since you know you want everything there is no problem.
You shouldn't do the work of the optimizer, it knows better how to
optimize a query in the most efficient way. There are at least two
problems with SELECT * :
1) It might return a lot of unnecessary columns, especially when doing
complicated JOINs.
2) The order in which the fields are returned might not always be the
same. If your application depends on that (there are situations where
this can be an issue), then it might fail at some time.
Don't you think there's a reason why the MySQL team itself warns that
you should _never_ rely on using SELECT *, except maybe for testing or
debugging purposes?
Micha
Navigation:
[Reply to this message]
|