|
把2个not exists合并还能快
不过都比不上第2个
SQL> WITH d AS (
2 SELECT LEVEL n1, 99999-LEVEL n2, LEVEL||(99999-LEVEL) s, TO_CHAR(LEVEL*(99999-LEVEL)) s2
3 FROM DUAL
4 CONNECT BY LEVEL<99999/2
5 )
6 SELECT n1,n2,n1*n2
7 FROM d
8 WHERE INSTR(s2,'0')>0
9 AND INSTR(s2,'1')>0
10 AND INSTR(s2,'2')>0
11 AND INSTR(s2,'3')>0
12 AND INSTR(s2,'4')>0
13 AND INSTR(s2,'5')>0
14 AND INSTR(s2,'6')>0
15 AND INSTR(s2,'7')>0
16 AND INSTR(s2,'8')>0
17 AND INSTR(s2,'9')>0
18 AND INSTR(s,'0')>0
19 AND INSTR(s,'1')>0
20 AND INSTR(s,'2')>0
21 AND INSTR(s,'3')>0
22 AND INSTR(s,'4')>0
23 AND INSTR(s,'5')>0
24 AND INSTR(s,'6')>0
25 AND INSTR(s,'7')>0
26 AND INSTR(s,'8')>0
27 AND INSTR(s,'9')>0
28 ;
N1 N2 N1*N2
---------- ---------- ----------
47931 52068 2495671308
已用时间: 00: 00: 00.14
SQL> with t as(select level l,99999-level l2 from dual connect by level<99999/2),
2 b as(select level-1 b from dual connect by level<=10)
3 select l, l2,l*l2 p from t
4 where not exists(select 1 from b where instr(l*l2,b)=0 or instr(l||l2,b)=0);
L L2 P
---------- ---------- ----------
47931 52068 2495671308
已用时间: 00: 00: 00.39 |
|