Taking care with your select projections can speed up your retrievals. In other words, don't select fields you don't need.
The select projection using the wildcard (*)
Using the wildcard guarantees all columns from the selected tables will be returned. Few problems here:
- If you're joining to different tables there may be replicated column names in the results.
- It's unusual to require every single field in any given situation, so any extra fields returned is just an overhead both for sql and if you're passing more data than required back up to the application.
- It's a lazy development style. Specifying fields refreshes your mind and makes you think about the schema and ways to mature it.
select *
from tblWidgets
The targeted select projection
This time we specify that only the fields we want are returned, in this case the field is widget_name
select tw.widget_name
from tblWidgets tw
#SQL techniques,
#SQL