skip to main content
Designing JDBC applications for performance Optimization : Using database metadata methods : Avoiding search patterns
  

Try DataDirect Drivers Now

Avoiding search patterns

Using null arguments or search patterns in database metadata methods results in generating time-consuming queries. In addition, network traffic potentially increases due to unwanted results. Always supply as many non-null arguments as possible to result sets that generate database metadata methods.
Because database metadata methods are slow, invoke them in your applications as efficiently as possible. Many applications pass the fewest non-null arguments necessary for the function to return success. For example:
ResultSet WSrs = WSdbmd.getTables(null, null, "WSTable", null);
In this example, an application uses the getTables() method to determine if the WSTable table exists. A JDBC driver interprets the request as: return all tables, views, system tables, synonyms, temporary tables, and aliases named "WSTable" that exist in any database schema inside the database catalog.
In contrast, the following request provides non-null arguments as shown:
String[] tableTypes = {"TABLE"};
WSdbmd.getTables("cat1", "johng", "WSTable", "tableTypes");
Clearly, a JDBC driver can process the second request more efficiently than it can process the first request.
Sometimes, little information is known about the object for which you are requesting information. Any information that the application can send the driver when calling database metadata methods can result in improved performance and reliability.