Oracle multi-threaded parallel use, association and specified index execution

copy code
CREATE TABLE T_SMAINT_2016012703 parallel 4 nologging AS
SELECT /*+parallel(4) leading(s a) use_hash(A) index(s IDX_CS_SERVICE_RECORD_MD2_04) */S.SMAINT_ID, S.SMAINT_DESC
  FROM T_CS_SERVICE_RECORD S
  JOIN T_CD_MAINT A
    ON A.SMAINT_ID = S.SMAINT_ID
   AND S.SORG_ID = 'MDKT'
   AND A.SORG_ID = S.SORG_ID
   AND A.PROD_ID = 'KT'
   AND S.PUB_CREATE_DATE BETWEEN
       TO_DATE('2015-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND
       TO_DATE('2015-12-31 23:59:59', 'yyyy-mm-dd hh24:mi:ss');
copy code
parallel 4 nologging: Parallel (Parallel) use
/*+parallel(4) leading(s a) use_hash(A) index(s IDX_CS_SERVICE_RECORD_MD2_04) */
parallel(4): 4 processes are used in parallel
leading(sa): specifies the query order of the table
First look up the s table, use the index IDX_CS_SERVICE_RECORD_MD2_04 to query the result set according to the S.PUB_CREATE_DATE condition, and then use the hash connection to associate the a table.
Hash joins consume a lot of CPU and memory, while nested loops are a lot less.
As shown in the above example, if nested loops are used, the result set is queried row by row according to the s table, and the data associated with the a table loop is queried.
Use leading and use_nl to set the query order of the table to speed up the query. Generally, the small table is set as the first table.
/*+LEADING(TABLE)*/
  Make the specified table the first table in the join order.
/*+USE_NL(TABLE)*/
  Joins the specified table with the nested join row source, and treats the specified table as an inner table.


1. Inquiry
Sql code  
SELECT /*+ Parallel(t,8) */ * FROM emp t;  
SELECT /*+ Parallel(8) */ * FROM emp t;  
SELECT /*+ Parallel */ * FROM emp t;         
 
2. Create an index
Sql code  
create index idx_emp_test on emp(empno,ename,job) nologging parallel 32;  
         When creating an index, be sure to add parallelism if possible! The ExaData server on the customer's side creates an index on the waybill table (more than 50 million records, more than 90 fields, and more than 60 GB of data). The index field contains 6 columns, and the parallelism is set to 64. It takes only 13 seconds to create the index. More, surprise me...

 Source: http://www.cnblogs.com/chenv/p/5165282.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325524477&siteId=291194637