分类: Oracle
2014-09-29 17:31:45
SELECT B.ID, B.NAME, B.TASK_ID, B.DICTION, B.GROUP_ID, NVL(B.ATTEST_FLAG, 'N'), NVL(B.DOUWIN_FLAG, 'N'), B.DESC, NVL(B.SIGN_FLAG, 'N'), B.MAX_EXECUTE_NUM FROM (SELECT DISTINCT (ID) FROM TEST_TAB WHERE STATUS = '04' AND CHN_TYPE = :B1) A, TABLE(CAST(:B2 AS TYPE_INFO_TABLE)) B WHERE A.ID = B.ID |
Plan hash value: 918180822 ----------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 839 (100)| | |* 1 | HASH JOIN | | 5784 | 75192 | 839 (5)| 00:00:05 | | 2 | COLLECTION ITERATOR PICKLER FETCH| | | | | | | 3 | VIEW | | 12361 | 132K| 818 (5)| 00:00:05 | | 4 | HASH UNIQUE | | 12361 | 301K| 818 (5)| 00:00:05 | |* 5 | TABLE ACCESS FULL | TEST_TAB | 21104 | 515K| 814 (4)| 00:00:05 | ----------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - access("A"."ID"=SYS_OP_ATG(VALUE(KOKBF$),1,2,2)) 5 - filter(("CHN_TYPE"=:B1 AND "STATUS"='04')) |
SQL> explain plan for 2 SELECT * 3 FROM TABLE(CAST(:B2 AS TYPE_INFO_TABLE)); Explained. Elapsed: 00:00:00.01 SQL> select * from table(dbms_xplan.display); PLAN_TABLE_OUTPUT ---------------------------------------------------------------------------------------- Plan hash value: 1692170009 ------------------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 8168 | 16336 | 14 (0)| 00:00:01 | | 1 | COLLECTION ITERATOR PICKLER FETCH| | | | | | ------------------------------------------------------------------------------------------ |
SQL> explain plan for 2 select/*+cardinality(b 100)*/ * from 3 TABLE(CAST(:B2 AS TYPE_INFO_TABLE)) B; Explained. Elapsed: 00:00:00.06 SQL> select * from table(dbms_xplan.display); PLAN_TABLE_OUTPUT ---------------------------------------------------------------------------------------- Plan hash value: 1692170009 ------------------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 100 | 200 | 20 (0)| 00:00:01 | | 1 | COLLECTION ITERATOR PICKLER FETCH| | | | | | ------------------------------------------------------------------------------------------ 8 rows selected. |
SQL> explain plan for 2 select/*+opt_estimate(table,b,rows=100)*/ * from 3 TABLE(CAST(:B2 AS TYPE_INFO_TABLE)) B; Explained. Elapsed: 00:00:00.01 SQL> select * from table(dbms_xplan.display); PLAN_TABLE_OUTPUT ---------------------------------------------------------------------------------------- Plan hash value: 1692170009 ------------------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 100 | 200 | 20 (0)| 00:00:01 | | 1 | COLLECTION ITERATOR PICKLER FETCH| | | | | | ------------------------------------------------------------------------------------------ 8 rows selected. Elapsed: 00:00:00.04 |
SELECT/*+cardinality(b 100)*/ B.ID, B.NAME, B.TASK_ID, B.DICTION, B.GROUP_ID,NVL(B.ATTEST_FLAG,'N'), NVL(B.DOUWIN_FLAG,'N'), B.DESC, NVL(B.SIGN_FLAG,'N'),B.MAX_EXECUTE_NUM FROM TABLE(CAST(:B2 AS TYPE_INFO_TABLE)) B WHERE EXISTS(SELECT 1 FROM TEST_TAB A WHERE A.STATUS = '04' AND A.CHN_TYPE = :B1 AND A.ID = B.ID ); |
Plan hash value: 3464704515 ------------------------------------------------------------------------------------------------------------------------------------------ | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem | ------------------------------------------------------------------------------------------------------------------------------------------ |* 1 | HASH JOIN | | 1 | 1787 | 75 |00:00:00.27 | 4283 | 1959K| 1363K| 2182K (0)| | 2 | VIEW | | 1 | 3807 | 27100 |00:00:00.25 | 4283 | | | | | 3 | HASH UNIQUE | | 1 | 3807 | 27100 |00:00:00.25 | 4283 | 1983K| 1380K| 1725K (0)| |* 4 | TABLE ACCESS FULL | TEST_TAB | 1 | 4281 | 208K|00:00:00.21 | 4283 | | | | | 5 | COLLECTION ITERATOR PICKLER FETCH| | 1 | | 75 |00:00:00.01 | 0 | | | | ------------------------------------------------------------------------------------------------------------------------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 1 - access("A"."ID"=SYS_OP_ATG(VALUE(KOKBF$),1,2,2)) 4 - filter(("CHN_TYPE"=:B1 AND "STATUS"='04')) |
Plan hash value: 884413475 ------------------------------------------------------------------------------------------------------------------ | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | ------------------------------------------------------------------------------------------------------------------ | 1 | NESTED LOOPS SEMI | | 1 | 1 | 75 |00:00:00.01 | 227 | | 2 | COLLECTION ITERATOR PICKLER FETCH| | 1 | | 75 |00:00:00.01 | 0 | |* 3 | TABLE ACCESS BY INDEX ROWID | TEST_TAB | 75 | 1 | 75 |00:00:00.01 | 227 | |* 4 | INDEX RANGE SCAN | PK_TEST_TAB | 75 | 2 | 75 |00:00:00.01 | 152 | ------------------------------------------------------------------------------------------------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 3 - filter("A"."STATUS"='04') 4 - access("A"."ID"=SYS_OP_ATG(VALUE(KOKBF$),1,2,2) AND "A"."CHN_TYPE"=:B2) filter("A"."CHN_TYPE"=:B2) |