You can use the ORDERED directive to instruct the query optimizer to join tables in the order in which they are listed in the FROM clause. If you do not include the ORDERED keyword, the query optimizer uses the order in which the tables are joined.
For example, the following statement allows the optimizer to choose the order in which the tables listed in the FROM clause to join these tables:
SELECT e.ename, d.dname, h.startdate FROM emp e, dept d, jobhist h WHERE d.deptno = e.deptno AND h.empno = e.empno;
The following statement instructs the optimizer to join the tables in specified order:
SELECT /*+ ORDERED */ e.ename, d.dname, h.startdate FROM emp e, dept d, jobhist h WHERE d.deptno = e.deptno AND h.empno = e.empno;
In the ORDERED version of the statement, a PolarDB O Edition joins emp e with dept d and then joins the result of the previous join with jobhist h. Without the ORDERED directive, the query optimizer specifies the join order.