Databases Reference
In-Depth Information
the driver (that is, some applications use SELECT * FROM table ...) .Ifthe
Select list contains long data, the driver is forced to retrieve that long data, even
if the application never requests the long data from the result set. For example,
consider the following code:
ResultSet rs = stmt.executeQuery (
"SELECT * FROM employees WHERE SSID = '999-99-2222'");
rs.next();
string name = rs.getString(1);
When a query is executed, the driver has no way to determine which result
columns the application will use; an application may fetch any result column that
is retrieved. When the driver processes a ResultSet.next() request, it retrieves
at least one, and often multiple, result rows from the database across the network.
A result row contains all the column values for each row. What if one of the
columns includes long data such as an employee photograph? Performance
would slow 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:
ResultSet rs = stmt.executeQuery (
"SELECT name FROM employees" +
"WHERE SSID = '999-99-2222'");
rs.next();
string name = rs.getString(1);
Although the methods of the Blob and Clob interfaces allow an application
to control how long data is retrieved, it's important to understand that drivers
often emulate the getBlob() and getClob() methods because many databases
do not support true Large Object (LOB) locators or because of the complexity of
mapping LOBs to the JDBC model. For example, an application may execute
Search WWH ::




Custom Search