Databases Reference
In-Depth Information
Using Database Metadata Methods
Database metadata methods retrieve information about a result set, such as the
number and type of columns. Because database metadata methods that generate
ResultSet objects are slow compared to other JDBC methods, using them fre-
quently can impair performance. Use the guidelines in this section to optimize
performance when selecting and using database metadata.
Minimizing the Use of Database Metadata Methods
Compared to other JDBC methods, database metadata methods that generate
result sets are slow. To retrieve all result column information mandated by the
JDBC specification, a JDBC driver often must perform multiple or complex
queries to retrieve the result set for a single call to a database metadata method.
Performance Tip
Although it's almost impossible to write a JDBC application without using
a database metadata method, you can improve performance by minimiz-
ing their use.
In addition, to avoid executing database metadata methods multiple times,
you should cache information retrieved from result sets generated by database
metadata methods. For example, call getTypeInfo() once, and cache the ele-
ments of the result set that your application depends on. It's unlikely that any
application will use all elements of the result set generated by a database meta-
data method, so the cache of information shouldn't be difficult to maintain.
Avoiding Search Patterns
Database metadata methods support arguments that can limit the amount of
data retrieved. Using null values or search patterns, such as %A% , for these argu-
ments often generates time-consuming queries. In addition, network traffic can
increase because of unnecessary results.
Performance Tip
Always supply as many non-null arguments as possible to result sets that
generate database metadata methods.
 
 
 
Search WWH ::




Custom Search