MySQL Query - select fields

If I have a mySQL table with 10 fields, and I only need to get the values ​​of some fields, is it advisable to use

SELECT field1, field2, field3 FROM...

but not

SELECT * FROM...

I mean this makes it easier to search / script execution faster if Im uses [SELECT field1, field2, field3 ....]

0
source share
4 answers

yes, you should request only those fields that you need, since the unnecessary fields will occupy the network resource (transportation from the db server to the backend server) and memory.

0
source

Yes, if you need only a small selection of fields in the table, it is better to select them, and not pull all the fields back. The difference is not huge, but for every optimization it can help.

20 18 , / *, .

.

0

, SELECT field1, field2, field3... .

* , , , .

, . , , .

0

a table 6800 , 23 Columns

C *Average value required to return records0.0009 Sec

And the same request with 5 Columnsaccepted average0.0005 Sec

Tested on Dual Core Machine 2GB RAM, Windows 7andPhpmyadmin

Conclusion

It is always recommended to use required fields, regardless of *where the speed is a priority

0
source

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


All Articles