|
|
在家里9201上测试
- SQL> select * from v$version;
- BANNER
- ----------------------------------------------------------------
- Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
- PL/SQL Release 9.2.0.1.0 - Production
- CORE 9.2.0.1.0 Production
- TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
- NLSRTL Version 9.2.0.1.0 - Production
- 已用时间: 00: 00: 00.00
- SQL> with t as(select x from (select level+122 x from dual connect by level<=(987-122))
- 2 where substr(x,1,1)<>substr(x,2,1) and substr(x,1,1)<>substr(x,3,1)
- 3 and substr(x,2,1)<>substr(x,3,1) and instr(x,0)=0),
- 4 a as (select rownum rn,x from t where x<494)
- 5 select count(*) from (
- 6 select a.x||'+'||b.x||'-'||c.x||'==0' from a a,t b,t c
- 7 where a.x+b.x-c.x=0 and a.x<494 and a.x<b.x --and b.x<c.x
- 8 and not exists(select 1 from (select rownum l from dual connect by level<=9)where instr(a.x||b.x||c.x ,l,1,2)>0))
- 9 ;
- COUNT(*)
- ----------
- 168
- 已用时间: 00: 00: 30.07
- SQL> with tmp as(
- 2 select a.num from (select rownum as num from dual connect by rownum <= 999) a
- 3 where substr(a.num,1,1) != substr(a.num,2,1)
- 4 and substr(a.num,3,1) != substr(a.num,2,1)
- 5 and substr(a.num,1,1) != substr(a.num,3,1) and instr(a.num,0)=0
- 6 and a.num >= 123 and a.num<=987)
- 7 --
- 8 select count(*) from(
- 9 select
- 10 a.num || '+' || b.num || '=' || c.num as str
- 11 from tmp a, tmp b, tmp c
- 12 where replace(replace(replace(
- 13 replace(replace(replace(
- 14 replace(replace(replace('123456789',substr(a.num,1,1)),substr(a.num,2,1)),substr(a.num,3,1)),
- 15 substr(b.num,1,1)),substr(b.num,2,1)),substr(b.num,3,1)),
- 16 substr(c.num,1,1)),substr(c.num,2,1)),substr(c.num,3,1)) is null
- 17 and a.num + b.num = c.num
- 18 and a.num < b.num
- 19 and b.num < c.num
- 20 );
- COUNT(*)
- ----------
- 168
- 已用时间: 00: 00: 00.05
- SQL> with tmp as(
- 2 select a.num from (select rownum as num from dual connect by rownum <= 999) a
- 3 where substr(a.num,1,1) != substr(a.num,2,1)
- 4 and substr(a.num,3,1) != substr(a.num,2,1)
- 5 and substr(a.num,1,1) != substr(a.num,3,1) and instr(a.num,0)=0
- 6 and a.num >= 123 and a.num<=987)
- 7 --
- 8 select count(*) from(
- 9 select
- 10 a.num || '+' || b.num || '=' || c.num as str
- 11 from tmp a, tmp b, tmp c
- 12 where translate('123456789','$'||a.num||b.num||c.num,'$') is null
- 13 and a.num + b.num = c.num
- 14 and a.num < b.num
- 15 and b.num < c.num
- 16 );
- COUNT(*)
- ----------
- 168
- 已用时间: 00: 00: 00.05
- SQL> with t as(select x from (select level+122 x from dual connect by level<=(987-122))
- 2 where substr(x,1,1)<>substr(x,2,1) and substr(x,1,1)<>substr(x,3,1)
- 3 and instr(x,0)=0)
- 4 select count(*) from (
- 5 select /*+rule */a.x||'+'||b.x||'-'||c.x||'==0' from t a,t b,t c
- 6 where a.x+b.x-c.x=0 and a.x<494 and a.x<b.x and b.x<c.x
- 7 and translate('123456789','$'||a.x||b.x||c.x,'$') is null)
- 8 ;
- ^C终止批处理操作吗(Y/N)? y
- 已连接。
- SQL> with t as(select x from (select level+122 x from dual connect by level<=(987-122))
- 2 where substr(x,1,1)<>substr(x,2,1) and substr(x,1,1)<>substr(x,3,1)
- 3 and instr(x,0)=0)
- 4 select count(*) from (
- 5 select a.x||'+'||b.x||'-'||c.x||'==0' from t a,t b,t c
- 6 where
- 7 translate('123456789','$'||a.x||b.x||c.x,'$') is null
- 8 and a.x+b.x-c.x=0 and a.x<494 and a.x<b.x and b.x<c.x
- 9 )
- 10 ;
- COUNT(*)
- ----------
- 168
- 已用时间: 00: 00: 16.06
- SQL>
- SQL> with t as(select x from (select level+122 x from dual connect by level<=(987-122))
- 2 where substr(x,1,1)<>substr(x,2,1) and substr(x,1,1)<>substr(x,3,1) and substr(x,2,1)<>substr(x,3,1)
- 3 and instr(x,0)=0)
- 4 select count(*) from (
- 5 select a.x||'+'||b.x||'-'||c.x||'==0' from t a,t b,t c
- 6 where
- 7 translate('123456789','$'||a.x||b.x||c.x,'$') is null
- 8 and a.x+b.x-c.x=0 and a.x<494 and a.x<b.x and b.x<c.x
- 9 )
- 10 ;
- COUNT(*)
- ----------
- 168
- 已用时间: 00: 00: 10.05
- SQL> explain plan for with t as(select x from (select level+122 x from dual connect by level<=(987-122))
- 2 where substr(x,1,1)<>substr(x,2,1) and substr(x,1,1)<>substr(x,3,1) and substr(x,2,1)<>substr(x,3,1)
- 3 and instr(x,0)=0)
- 4 select count(*) from (
- 5 select a.x||'+'||b.x||'-'||c.x||'==0' from t a,t b,t c
- 6 where
- 7 translate('123456789','$'||a.x||b.x||c.x,'$') is null
- 8 and a.x+b.x-c.x=0 and a.x<494 and a.x<b.x and b.x<c.x
- 9 )
- 10 ;
- 已解释。
- 已用时间: 00: 00: 00.01
- SQL> select * from table(dbms_xplan.display);
- PLAN_TABLE_OUTPUT
- ------------------------------------------------------------------------------------------------------------------------------------
- --------------------------------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost |
- --------------------------------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | | | |
- | 2 | TEMP TABLE TRANSFORMATION | | | | |
- | 1 | RECURSIVE EXECUTION | SYS_LE_2_0 | | | |
- | 0 | INSERT STATEMENT | | | | |
- | 1 | LOAD AS SELECT | | | | |
- | 2 | VIEW | | | | |
- |* 3 | FILTER | | | | |
- | 4 | CONNECT BY WITH FILTERING | | | | |
- | 5 | NESTED LOOPS | | | | |
- | 6 | TABLE ACCESS FULL | DUAL | | | |
- | 7 | TABLE ACCESS BY USER ROWID| DUAL | | | |
- | 8 | NESTED LOOPS | | | | |
- | 9 | BUFFER SORT | | | | |
- | 10 | CONNECT BY PUMP | | | | |
- |* 11 | FILTER | | | | |
- | 12 | TABLE ACCESS FULL | DUAL | | | |
- | 3 | SORT AGGREGATE | | | | |
- | 4 | NESTED LOOPS | | | | |
- | 5 | NESTED LOOPS | | | | |
- | 6 | VIEW | | | | |
- | 7 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6606_109DBD8 | | | |
- |* 8 | VIEW | | | | |
- | 9 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6606_109DBD8 | | | |
- |* 10 | VIEW | | | | |
- | 11 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6606_109DBD8 | | | |
- --------------------------------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- 3 - filter(INSTR(TO_CHAR(LEVEL+122),'0')=0 AND SUBSTR(TO_CHAR(LEVEL+122),2,1)<>SUBSTR(TO_CHA
- R(LEVEL+122),3,1) AND SUBSTR(TO_CHAR(LEVEL+122),1,1)<>SUBSTR(TO_CHAR(LEVEL+122),3
- ,1) AND SUBSTR(TO_CHAR(LEVEL+122),1,1)<>SUBSTR(TO_CHAR(LEVEL+122),2,1))
- 11 - filter(LEVEL<=865)
- 8 - filter("B"."X"<"C"."X")
- 10 - filter("A"."X"<"B"."X" AND "A"."X"<494 AND "A"."X"+"B"."X"-"C"."X"=0 AND TRANSLATE('1234
- 56789','$'||TO_CHAR("A"."X")||TO_CHAR("B"."X")||TO_CHAR("C"."X"),'$') IS NULL)
- Note: rule based optimization
- 已选择43行。
- 已用时间: 00: 00: 00.07
- SQL> explain plan for with t as(select x from (select level+122 x from dual connect by level<=(987-122))
- 2 where substr(x,1,1)<>substr(x,2,1) and substr(x,1,1)<>substr(x,3,1)
- 3 and instr(x,0)=0)
- 4 select count(*) from (
- 5 select /*+rule */a.x||'+'||b.x||'-'||c.x||'==0' from t a,t b,t c
- 6 where a.x+b.x-c.x=0 and a.x<494 and a.x<b.x and b.x<c.x
- 7 and translate('123456789','$'||a.x||b.x||c.x,'$') is null)
- 8 ;
- 已解释。
- 已用时间: 00: 00: 00.00
- SQL> select * from table(dbms_xplan.display);
- PLAN_TABLE_OUTPUT
- ------------------------------------------------------------------------------------------------------------------------------------
- --------------------------------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost |
- --------------------------------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | | | |
- | 2 | TEMP TABLE TRANSFORMATION | | | | |
- | 1 | RECURSIVE EXECUTION | SYS_LE_2_0 | | | |
- | 0 | INSERT STATEMENT | | | | |
- | 1 | LOAD AS SELECT | | | | |
- | 2 | VIEW | | | | |
- |* 3 | FILTER | | | | |
- | 4 | CONNECT BY WITH FILTERING | | | | |
- | 5 | NESTED LOOPS | | | | |
- | 6 | TABLE ACCESS FULL | DUAL | | | |
- | 7 | TABLE ACCESS BY USER ROWID| DUAL | | | |
- | 8 | NESTED LOOPS | | | | |
- | 9 | BUFFER SORT | | | | |
- | 10 | CONNECT BY PUMP | | | | |
- |* 11 | FILTER | | | | |
- | 12 | TABLE ACCESS FULL | DUAL | | | |
- | 3 | SORT AGGREGATE | | | | |
- | 4 | NESTED LOOPS | | | | |
- | 5 | NESTED LOOPS | | | | |
- | 6 | VIEW | | | | |
- | 7 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6607_109DBD8 | | | |
- |* 8 | VIEW | | | | |
- | 9 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6607_109DBD8 | | | |
- |* 10 | VIEW | | | | |
- | 11 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6607_109DBD8 | | | |
- --------------------------------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- 3 - filter(INSTR(TO_CHAR(LEVEL+122),'0')=0 AND SUBSTR(TO_CHAR(LEVEL+122),1,1)<>SUBSTR(TO_CHA
- R(LEVEL+122),3,1) AND SUBSTR(TO_CHAR(LEVEL+122),1,1)<>SUBSTR(TO_CHAR(LEVEL+122),2
- ,1))
- 11 - filter(LEVEL<=865)
- 8 - filter("B"."X"<"C"."X")
- 10 - filter(TRANSLATE('123456789','$'||TO_CHAR("A"."X")||TO_CHAR("B"."X")||TO_CHAR("C"."X"),'
- $') IS NULL AND "A"."X"<"B"."X" AND "A"."X"<494 AND "A"."X"+"B"."X"-"C"."X"=0)
- Note: rule based optimization
- 已选择43行。
- 已用时间: 00: 00: 00.01
- SQL> explain plan for with tmp as(
- 2 select a.num from (select rownum as num from dual connect by rownum <= 999) a
- 3 where substr(a.num,1,1) != substr(a.num,2,1)
- 4 and substr(a.num,3,1) != substr(a.num,2,1)
- 5 and substr(a.num,1,1) != substr(a.num,3,1) and instr(a.num,0)=0
- 6 and a.num >= 123 and a.num<=987)
- 7 --
- 8 select count(*) from(
- 9 select
- 10 a.num || '+' || b.num || '=' || c.num as str
- 11 from tmp a, tmp b, tmp c
- 12 where translate('123456789','$'||a.num||b.num||c.num,'$') is null
- 13 and a.num + b.num = c.num
- 14 and a.num < b.num
- 15 and b.num < c.num
- 16 );
- 已解释。
- 已用时间: 00: 00: 00.00
- SQL> select * from table(dbms_xplan.display);
- PLAN_TABLE_OUTPUT
- ------------------------------------------------------------------------------------------------------------------------------------
- --------------------------------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost |
- --------------------------------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | | | |
- | 2 | TEMP TABLE TRANSFORMATION | | | | |
- | 1 | RECURSIVE EXECUTION | SYS_LE_2_0 | | | |
- | 0 | INSERT STATEMENT | | | | |
- | 1 | LOAD AS SELECT | | | | |
- |* 2 | VIEW | | | | |
- |* 3 | COUNT STOPKEY | | | | |
- | 4 | CONNECT BY WITH FILTERING | | | | |
- | 5 | NESTED LOOPS | | | | |
- | 6 | TABLE ACCESS FULL | DUAL | | | |
- | 7 | TABLE ACCESS BY USER ROWID| DUAL | | | |
- | 8 | NESTED LOOPS | | | | |
- | 9 | BUFFER SORT | | | | |
- | 10 | CONNECT BY PUMP | | | | |
- | 11 | TABLE ACCESS FULL | DUAL | | | |
- | 3 | SORT AGGREGATE | | | | |
- | 4 | MERGE JOIN | | | | |
- | 5 | SORT JOIN | | | | |
- | 6 | NESTED LOOPS | | | | |
- | 7 | VIEW | | | | |
- | 8 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6608_109DBD8 | | | |
- |* 9 | VIEW | | | | |
- | 10 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6608_109DBD8 | | | |
- |* 11 | FILTER | | | | |
- |* 12 | SORT JOIN | | | | |
- | 13 | VIEW | | | | |
- | 14 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6608_109DBD8 | | | |
- --------------------------------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- 2 - filter("A"."NUM"<=987 AND "A"."NUM">=123 AND INSTR(TO_CHAR("A"."NUM"),'0')=0 AND SUBSTR(
- TO_CHAR("A"."NUM"),1,1)<>SUBSTR(TO_CHAR("A"."NUM"),3,1) AND SUBSTR(TO_CHAR("A"."N
- UM"),3,1)<>SUBSTR(TO_CHAR("A"."NUM"),2,1) AND SUBSTR(TO_CHAR("A"."NUM"),1,1)<>SUB
- STR(TO_CHAR("A"."NUM"),2,1))
- 3 - filter(ROWNUM<=999)
- 9 - filter("A"."NUM"<"B"."NUM")
- 11 - filter("B"."NUM"<"C"."NUM" AND TRANSLATE('123456789','$'||TO_CHAR("A"."NUM")||TO_CHAR("B
- "."NUM")||TO_CHAR("C"."NUM"),'$') IS NULL)
- 12 - access("C"."NUM"="A"."NUM"+"B"."NUM")
- filter("C"."NUM"="A"."NUM"+"B"."NUM")
- Note: rule based optimization
- 已选择48行。
- 已用时间: 00: 00: 00.01
- SQL>
- SQL> explain plan for with t as(select x from (select level+122 x from dual connect by level<=(987-122))
- 2 where substr(x,1,1)<>substr(x,2,1) and substr(x,1,1)<>substr(x,3,1) and substr(x,2,1)<>substr(x,3,1)
- 3 and instr(x,0)=0)
- 4 select count(*) from (
- 5 select /*+rule */a.x||'+'||b.x||'-'||c.x||'==0' from t a,t b,t c
- 6 where a.x+b.x-c.x=0 and a.x<494 and a.x<b.x and b.x<c.x
- 7 and translate('123456789','$'||a.x||b.x||c.x,'$') is null)
- 8 ;
- 已解释。
- 已用时间: 00: 00: 00.00
- SQL> select * from table(dbms_xplan.display);
- PLAN_TABLE_OUTPUT
- --------------------------------------------------------------------------------------------------------------------
- --------------------------------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost |
- --------------------------------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | | | |
- | 2 | TEMP TABLE TRANSFORMATION | | | | |
- | 1 | RECURSIVE EXECUTION | SYS_LE_2_0 | | | |
- | 0 | INSERT STATEMENT | | | | |
- | 1 | LOAD AS SELECT | | | | |
- | 2 | VIEW | | | | |
- |* 3 | FILTER | | | | |
- | 4 | CONNECT BY WITH FILTERING | | | | |
- | 5 | NESTED LOOPS | | | | |
- | 6 | TABLE ACCESS FULL | DUAL | | | |
- | 7 | TABLE ACCESS BY USER ROWID| DUAL | | | |
- | 8 | NESTED LOOPS | | | | |
- | 9 | BUFFER SORT | | | | |
- | 10 | CONNECT BY PUMP | | | | |
- |* 11 | FILTER | | | | |
- | 12 | TABLE ACCESS FULL | DUAL | | | |
- | 3 | SORT AGGREGATE | | | | |
- | 4 | NESTED LOOPS | | | | |
- | 5 | NESTED LOOPS | | | | |
- | 6 | VIEW | | | | |
- | 7 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6609_109DBD8 | | | |
- |* 8 | VIEW | | | | |
- | 9 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6609_109DBD8 | | | |
- |* 10 | VIEW | | | | |
- | 11 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6609_109DBD8 | | | |
- --------------------------------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- 3 - filter(INSTR(TO_CHAR(LEVEL+122),'0')=0 AND SUBSTR(TO_CHAR(LEVEL+122),2,1)<>SUBSTR(TO_CHA
- R(LEVEL+122),3,1) AND SUBSTR(TO_CHAR(LEVEL+122),1,1)<>SUBSTR(TO_CHAR(LEVEL+122),3
- ,1) AND SUBSTR(TO_CHAR(LEVEL+122),1,1)<>SUBSTR(TO_CHAR(LEVEL+122),2,1))
- 11 - filter(LEVEL<=865)
- 8 - filter("B"."X"<"C"."X")
- 10 - filter(TRANSLATE('123456789','$'||TO_CHAR("A"."X")||TO_CHAR("B"."X")||TO_CHAR("C"."X"),'
- $') IS NULL AND "A"."X"<"B"."X" AND "A"."X"<494 AND "A"."X"+"B"."X"-"C"."X"=0)
- Note: rule based optimization
- 已选择43行。
- 已用时间: 00: 00: 00.01
- SQL> with t as(select x from (select level+122 x from dual connect by level<=(987-122))
- 2 where substr(x,1,1)<>substr(x,2,1) and substr(x,1,1)<>substr(x,3,1) and substr(x,2,1)<>substr(x,3,1)
- 3 and instr(x,0)=0)
- 4 select count(*) from (
- 5 select /*+rule */a.x||'+'||b.x||'-'||c.x||'==0' from t a,t b,t c
- 6 where a.x+b.x-c.x=0 and a.x<494 and a.x<b.x and b.x<c.x
- 7 and translate('123456789','$'||a.x||b.x||c.x,'$') is null)
- 8 ;
- ^C终止批处理操作吗(Y/N)? y
复制代码 |
|