My Oracle Support Banner

Subquery Factoring (WITH) Clause (Doc ID 1662498.1)

Last updated on JUNE 13, 2023

Applies to:

Oracle Database - Enterprise Edition - Version 9.0.1.0 and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Oracle Database Backup Service - Version N/A and later
Information in this document applies to any platform.

Purpose

NOTE: In the images and/or the document content below, the user information and data used represents fictitious data from the Oracle sample schema(s) or Public Documentation delivered with an Oracle database product. Any similarity to actual persons, living or dead, is purely coincidental and not intended in any manner.

  

If similar subqueries appear more than once in a sql, it is worth trying to rewrite the query using WITH subquery.
There are some things we should consider in order to get the benefit from it.

Details

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Purpose
Details
 Subquery Factoring
 Things to Consider when Deciding to Use Subquery Factoring
 Examples of Subquery Factoring
 Influencing the Plan with Hints and Parameters
 Hints
 Optimizer Parameter
 Demonstration
 Query 1 - Without Subquery Factoring
 Query 1 - With Subquery Factoring
 Query 2 - Without Subquery Factoring
 Query 2 - With Subquery Factoring
  Documentation
References

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.