What is faster SELECT * or SELECT `field` when only" field "is required

I don’t want to assume here, I have already been bitten / proved.

Any help would be appreciated

+3
source share
7 answers

The SELECT field is faster than select *.

Because if your table has more than 1 field / column, then select *, it will return all of them, and this requires network bandwidth and more work for the database to retrieve all other fields. But if you only need one field / column, the database load will be less and it will not need to transfer unnecessary information and, therefore, it is unsafe to use bandwidth resources.

+15
source

@AntionoP SELECT field , , MySQL , .

+5

Select * , select <field list>, * .
, ( ), ?

+4

* , , blob. , .

+2

mysql, , "SELECT" . ?

Linux:

time (echo "SELECT * FROM table" | mysql -u username --password=passwd database > /dev/null)

time (echo "SELECT field FROM table" | mysql -u username --password=passwd database > /dev/null)
+1

SELECT * , . . MySQL? , SELECT * , , EXPLAIN (..query..).

However, the easiest way to be sure is to simply not use it SELECT *in production requests.

+1
source

Source: https://habr.com/ru/post/1775387/


All Articles