Oracle SQL
Tutorial -
How To Make Your SQL Lightning-Fast
Tip #7
- Name the Required Columns In
SQL Queries
Tip #7 in this
Oracle sql tutorial is to name the
columns in a query instead of using "select * from ..."
to indicate all the columns should be selected even if all the columns
are needed.
There are (at
least) three good reasons for this:-
- Network traffic is reduced.
This can have a significant impact on performance if the table has a
large number of columns, or the table has a long or long raw column
(both of which can be up to 2 Gigabytes in length) or LOBs (which can
be up to 3 gigabytes in size). These types of columns will take a long
time to transfer over the network and so they should not be fetched
from the database unless they are specifically required.
- The code is easier to understand,
which means you need fewer comments and maintenance will be faster and
therefore cheaper
- It could save the need for changes in
the future. Not only might columns be added to or removed
from the table or view, but the order of the columns could well change
(unlikely in a table but not impossible) - in which case using "SELECT *" at
best would fetch the wrong data and at worst would fail with an Oracle
error which might take a long while to understand.
Return
to Oracle SQL
Tutorial part 1
|