Do you only SELECT the columns you require?
Last updated by Bahjat Alaadel [SSW] 4 months ago.See historyIt can be expensive retrieving all the columns of a table. Find out why.
Video: SELECT only the columns you want ✨ | Bryden Oliver (4 min)
Retrieving all the columns in a table is a common pattern.
SELECT * FROM Users
This is not an unusual statement to see. However statements of this type should not be employed inside an application. It's important to minimise the number of columns returned by queries because:
- It takes more network bandwidth to transmit the results
- It takes extra CPU at the database and the caller to encode/decode the response
- In cases where all the columns required are available in an index, retrieving all columns can cause reading an index and then the main table to retrieve the remaining columns