|
Posted by Captain Paralytic on 08/03/07 12:18
On 3 Aug, 09:37, David Gillen <Bel...@RedBrick.DCU.IE> wrote:
> C. said:> On 2 Aug, 10:04, Michael Fesser <neti...@gmx.de> wrote:
> >> You shouldn't use "SELECT *" in production code, list all columns
> >> explicitly.
>
> >> Micha
>
> > You shouldn't use "SELECT *" in production code IF YOU CAN list all
> > columns
> > explicitly.
>
> > ...reason being that you're loading more data into the mysql buffer
> > than you need, then it gets copied into the PHP variable space.
>
> If I want all column in a table though surely SELECT * is better.
> 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 but just returns you
> everything and since you know you want everything there is no problem.
>
> D.
> --
> Fermat was right.
As well as what Micha said, there is another potential drawback.
Suppose someone added a TEXT BLOB field containing megabytes of data
to the table.
Any queries that used * would nowbe bringing back all that data each
time.
Navigation:
[Reply to this message]
|