SilverBlue
SilverBlue

Reputation: 269

Is the mySQL query SELECT * okay?

I select my query with

$result = mysql_query("SELECT * FROM xy WHERE id='$_POST[ID]'", $mysqlconnect1);
$logindat = mysql_fetch_array($result);

Is there any improvement when I call "SELECT XY FROM"?

Upvotes: 0

Views: 88

Answers (2)

Darshan Mehta
Darshan Mehta

Reputation: 30819

Performance wise, there won't be any difference. However, there might be some network traffic if you are fetching too many rows and table have massive number of columns. If you are interested in only a few columns, recommended approach is to use the column names in the query.

Also, performance will depend on whether there is any index on id column.

Upvotes: 1

Srihari Karanth
Srihari Karanth

Reputation: 2167

There will be no difference in performance from * to each column name. * will internally resolve to each column name. It will be helpful to have reduced number of column in select clause only if there are aggregation functions involved.

Upvotes: 1

Related Questions