Iterative query processing involves using query rewriting to generate an SQL query for retrieving the values of single-valued attributes appearing in a select clause and for evaluating conditions involving single-valued comparisons, and retrieving separately (i.e., using different SQL queries) values of set-valued and derived attributes appearing in the select clause. Some conditions involving set-valued attributes (e.g., testing whether the values of a set-valued attribute contains a constant or the value of a single-valued attribute) can be also translated directly into SQL conditions. Other conditions involving set-valued attributes (e.g., set-comparison of set-valued attributes) do not have a straightforward translation, and can result in deeply nested (with multiple levels of not in or not exists SQL subqueries [1]) and inefficient SQL queries. Such conditions are processed iteratively by first retrieving the values of the set-valued attribute(s) involved in set-comparisons and then using a query processor external to the DBMS for evaluating the conditions.
For example, only query rewriting needs to be used for the query above because its associated condition does not involve set-valued comparisons and therefore can be translated directly into SQL conditions, and its select clause involves only a single-valued attribute.
The main purpose of the iterative query processing is to avoid the generation of SQL queries that are too complex, too dependent on the SQL dialect of a particular DBMS, or are inherently inefficient (e.g., avoid employing outerjoins which are both inefficient and supported differently by different DBMSs). By evaluating part of the OPM query conditions using SQL, this query processing strategy takes advantage of the underlying DBMS. At the same time, its query translation is relatively simple and avoids generating queries with numerous (outer)joins. Furthermore, retrieving set-valued attributes separately from single-valued attributes simplifies formatting (converting) the SQL query results into OPM class instances.