How Reformatted Queries Optimize Searches

Managing System Settings 4-19

4.2.5.3 How Reformatted Queries Optimize Searches

The majority of queries in an Oracle Content Server instance involve a small, targeted set of content items or return a hundred rows, at most. Oracle Content Server software can easily scale to millions of content items. However, testing on an Oracle database with a collection containing 10 million content items indicates that the execution plan that Oracle selects is not the most efficient. Oracle generally does not choose the best optimization strategies to resolve many queries, even some that are trivial. The following examples explain this issue: ■ Example 1: Reformatting a Query by Adding a Single Hint on page 4-19 ■ Example 2: Reformatting a Query by Adding Multiple Hints on page 4-19

4.2.5.3.1 Example 1: Reformatting a Query by Adding a Single Hint In the environment

described above, Oracle does not resolve the following query as efficiently as possible: SELECT FROM Revisions, Documents, DocMeta WHERE Revisions.dID = Documents.dID AND Revisions.dID = DocMeta.dID AND Revisions.dRevClassID = 333 Order By Revisions.dID Because a fairly selective index is available dRevClassID_2 for Revisions.dRevClassID, this query should access dRevClassID_2 and perform a sort on the rows that match the dRevClassID. However, in this query example, Oracle chooses to use the Revisions.dID index. This choice is actually worse than performing a full table scan on the Revisions table because it does a full index scan and accesses the table to obtain the dRevClassID for each row. Obviously, resolving the query using this execution plan does not work well when the Oracle Content Server repository has over 10 million content items. In this case, it requires approximately 500 seconds to return the results. However, the performance improves dramatically when the query is modified by adding a hint as follows: SELECT + INDEXRevisions dRevClassID_2 FROM Revisions, Documents, DocMeta WHERE Revisions.dID = Documents.dID AND Revisions.dID = DocMeta.dID AND Revisions.dRevClassID = 333 Order By Revisions.dID The query is modified by adding the following hint to the SELECT clause: + INDEXRevisions dRevClassID_2 This forces Oracle database to choose the dRevClassID_2 index instead of the index for Revisions.dID. Because no more than a few content items share dRevClassID in this example, the modified query returns the results instantly.

4.2.5.3.2 Example 2: Reformatting a Query by Adding Multiple Hints In a typical Oracle

Content Server instance, most documents have a Y released status for the dReleaseState with a dInDate earlier than the current date. However, only a few documents have an N new, not yet indexed status for the dReleaseState. The following query is searching for content items that have not yet been released: SELECT dID FROM Revisions 4-20 Oracle Fusion Middleware System Administrators Guide for Oracle Content Server WHERE Revisions.dReleaseState = NN AND Revisions.dStatus in NDONE, NRELEASED, NDELETED AND Revisions.dInDate={ts 2005-02-23 17:46:38.321} The optimized result for the query uses the index for dReleaseState: SELECT+ LEADINGRevisions INDEX Revisions dReleaseState dID FROM Revisions WHERE Revisions.dReleaseState = NN AND Revisions.dStatus in NDONE, NRELEASED, NDELETED AND Revisions.dInDate={ts 2005-02-23 17:46:38.321}

4.2.5.4 Types of Recognized Hints