Using * in SELECT Query

Possible duplicate:
Which is faster / better? SELECT * or SELECT column1, colum2, column3 etc.

I am currently porting an application written in MySQL3 and PHP4 to MySQL5 and PHP5.

In the analysis, I found several SQL queries that use "select * from tablename", even if only one column (field) is processed in PHP. The table has almost 60 columns and has a primary key. In most cases, the only column used is id , which is the primary key.

Will there be a performance improvement if I use queries that explicitly mention column names instead of *? (In this application, there is only one method that needs all the columns, and all other methods return only a subset of the columns)

+5
source share
7 answers

. , , , - . , 100k , , , , , .

, EXPLAIN, , .

+10

" - ". .

, Will there be any performance boost?. : " . ?"

99% "" . , , .

+4

, , of *? -

+2

. , , , MySQL PHP .., , , .

+1

, , , , , id, SQL.

( ) , , , . .

SQL, ( ).

+1

- , BLOB/CLOB, ( 300 ) - , , WHERE, (IMHO) SELECT *

.

+1

. . , . :

SELECT * FROM tabA JOIN tabB on... ORDER BY colX

, tabA colX, colX tabB, .

Of course, using table aliases for all fields will also help prevent breakage.

-Krip

+1
source

All Articles