A method and apparatus for processing queries is provided. A query is
received at a mid-tier node of a multi-tier system. The mid-tier node
includes a mid-tier cache that is configured to cache relational tables
from one or more databases managed by a database server in a database
tier of the multi-tier system. At the mid-tier node, a determination is
made whether the received query includes an operator for requesting data
of an XML datatype from the database server, where the XML datatype is
supported as a native datatype by the database server. If a determination
is made that the query includes such operator, then one or more portions
of one or more relational tables are retrieved from the database server
and stored in the mid-tier cache. The one or more relational tables
store, in the one or more portions, index information associated with the
requested data of the XML datatype. The received query is rewritten into
a relational query against at least the one or more portions of the one
or more relational tables that are stored in the mid-tier cache.