Nested Queries

While algorithms exist on some systems to convert any nested query into a flat join, the benefit of such algorithms is not always significant. Therefore, the server does not perform the conversion. Instead, the server continually makes use of feedback from intermediate results to avoid unnecessary searches. If the server methodology is not the most efficient for your data, you can restructure the query as a flat join.

When processing a nested query, the server first evaluates the inner query (subquery). Consider the following query:

SELECT * FROM dept 
    WHERE mgr IN 
        SELECT e_no FROM employee 
            WHERE city = "Wild Woods"

The XDB Server first finds all employees who live in Wild Woods, and modifies the nested query to process the outer query. If an index exists on MGR, it might be used after the nested query has been processed.