Skip to main content

Cached Queries

How efficient is this approach? With a predefined query, the analysis and optimization of a request are all carried out when a class is compiled, not when the query is run. With a dynamic query, on the other hand, you might think we need to carry out request analysis and optimization every time for every request. Fortunately, with Caché this is not the case.

For each dynamic query it processes, Caché remembers the query's source (e.g. the SQL SELECT request) as well as the optimized and compiled form of the query. Whenever a query is received, the system automatically checks whether a matching precompiled query is available. If so, it is run automatically, avoiding the normal query processing overhead.

In case you are worried about the database being overrun with saved queries that are never used again, you can purge the queries using the System Management Portal. Click System Explorer > SQL, and then click the Actions link and then click Purge Cached Queries. Use the Switch link at the top of the page to change namespaces, if necessary.

FeedbackOpens in a new tab