Databases Reference
In-Depth Information
sql = "SELECT * FROM employees
WHERE SSID = '999-99-2222'";
cmd.CommandText = sql;
dataReader = cmd.ExecuteReader();
dataReader.Read();
string name = dataReader.GetString(0);
When a query is executed, the data provider has no way to determine which
result columns the application will use; an application may fetch any of the result
columns that are retrieved. When the data provider processes the fetch request, it
retrieves at least one, and often multiple, result rows from the database across the
network. In this case, a result row contains all the column values for each row. If
one of the columns includes long data such as an employee photograph, perfor-
mance slows considerably.
Performance Tip
Because retrieving long data across the network negatively affects per-
formance, design your application to exclude long data from the Select
list.
Limiting the Select list to contain only the name column results in a faster
performing query at runtime. For example:
sql = "SELECT name FROM employees" +
"WHERE SSID = '999-99-2222'";
cmd.CommandText = sql;
dataReader = cmd.ExecuteReader();
dataReader.Read();
string name = dataReader.GetString(0);
Limiting the Amount of Data Retrieved
If your application executes a query that retrieves five rows when it needs only
two, application performance suffers, especially if the unnecessary rows include
long data.
 
Search WWH ::




Custom Search