oracle select the most efficient sequence table name

ORACLE parser processed in the order from right to left FROM table name clause , thus FROM clause written in the final table (base table driving table) will be processed first in the FROM clause including a plurality of table case, you must select the least number of records in the table as a base table. when processing a plurality of tables ORACLE, will use the combined sorting and connect them. Firstly, the scan of a table (FROM clause last the table) and the send sequence record, and then scanning the second table (fROM clause in the last second table), and finally all of the retrieved records from the second table and the first table records appropriate merge.

For example: Table TAB1 16,384 records

         Table records TAB2 1

     As the basis for selection table TAB2 (Best Method)

     select count (*) from tab1, tab2 execution time of 0.96 seconds

     As the basis for selection table TAB2 (bad way)

     select count (*) from tab2, tab1 execution time of 26.09 seconds

If there are three or more connection table queries, it would need to select the cross-table (intersection table) as a base table, cross table refers to the table that is referenced by other tables.

For example: EMP table describes the intersection LOCATION CATEGORY table and the table.

SELECT *

FROM LOCATION L ,

      CATEGORY C,

      EMP E

WHERE E.EMP_NO BETWEEN 1000 AND 2000

AND E.CAT_NO = C.CAT_NO

AND E.LOCN = L.LOCN

 The following SQL is more efficient than

SELECT *

FROM EMP E ,

LOCATION L ,

      CATEGORY C

WHERE  E.CAT_NO = C.CAT_NO

AND E.LOCN = L.LOCN

AND E.EMP_NO BETWEEN 1000 AND 2000

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11121768.html