Starting in Oracle9i release 2 we saw an incorporation of the SQL-99 WITH clause (a.k.a. subquery factoring), a tool for materializing subqueries to save Oracle from having to re-compute them multiple times.
The SQL WITH clause is very similar to the use of Global temporary tables (GTT), a technique that is often used to improve query speed for complex subqueries. Here are some important notes about the Oracle WITH clause:
? The SQL WITH clause only works on Oracle 9i release 2 and beyond.
? Formally, the WITH clause is called subquery factoring
? The SQL WITH clause is used when a subquery is executed multiple times
? Also useful for recursive queries (SQL-99, but not Oracle SQL)
Let?s take a closer look at how the Oracle SQL WITH clause works: