2

在 Oracle 中,我们限制了 SQL 的 IN 子句中仅支持 1000 个项目。我想知道Oracle中是否还有其他此类限制。

4

3 回答 3

3

此处记录了 11.2 的各种限制:http: //docs.oracle.com/cd/B28359_01/server.111/b28320/limits003.htm

一些基于版本的限制:http ://www.oracle.com/us/products/database/enterprise-edition/comparisons/index.html

于 2013-10-21T12:17:58.937 回答
1

有一个简单的技巧可以绕过这个限制。
我有时在临时查询中使用它。
在 Oracle 11.2g 上测试了 5000 个项目。
这种方法的缺点是解析时间长(在我的系统上 5000 个项目大约需要 5-10 秒)。

WITH list AS (
select 1 as X from dual union all
select 2 from dual union all
select 3 from dual union all
......
......
......
select 4997 from dual union all
select 4998 from dual union all
select 4999 from dual union all
select 5000 from dual 
)
SELECT /*+gather_plan_statistics */ * FROM table123
WHERE x IN ( SELECT * FROM list );



select * from table( dbms_xplan.display_cursor (format=>'ALLSTATS LAST'));
----------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                       
| Id  | Operation            | Name     | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |                                                                                                                                                                                       
----------------------------------------------------------------------------------------------------------------------                                                                                                                                                                                       
|   0 | SELECT STATEMENT     |          |      1 |        |   5000 |00:00:00.24 |      29 |       |       |          |                                                                                                                                                                                       
|*  1 |  HASH JOIN RIGHT SEMI|          |      1 |      1 |   5000 |00:00:00.24 |      29 |  1066K|  1066K| 1339K (0)|                                                                                                                                                                                       
|   2 |   VIEW               | VW_NSO_1 |      1 |   5000 |   5000 |00:00:00.24 |       0 |       |       |          |                                                                                                                                                                                       
|   3 |    VIEW              |          |      1 |   5000 |   5000 |00:00:00.21 |       0 |       |       |          |                                                                                                                                                                                       
|   4 |     UNION-ALL        |          |      1 |        |   5000 |00:00:00.18 |       0 |       |       |          |                                                                                                                                                                                       
|   5 |      FAST DUAL       |          |      1 |      1 |      1 |00:00:00.01 |       0 |       |       |          |                                                                                                                                                                                       
|   6 |      FAST DUAL       |          |      1 |      1 |      1 |00:00:00.01 |       0 |       |       |          |                                                                                                                                                                                       
|   7 |      FAST DUAL       |          |      1 |      1 |      1 |00:00:00.01 |       0 |       |       |          |                                                                                                                                                                                       
|   8 |      FAST DUAL       |          |      1 |      1 |      1 |00:00:00.01 |       0 |       |       |          |                                                                                                                                                                                       
|   9 |      FAST DUAL       |          |      1 |      1 |      1 |00:00:00.01 |       0 |       |       |          | 
..........
..........
..........
|5000 |      FAST DUAL       |          |      1 |      1 |      1 |00:00:00.01 |       0 |       |       |          |                                                                                                                                                                                       
|5001 |      FAST DUAL       |          |      1 |      1 |      1 |00:00:00.01 |       0 |       |       |          |                                                                                                                                                                                       
|5002 |      FAST DUAL       |          |      1 |      1 |      1 |00:00:00.01 |       0 |       |       |          |                                                                                                                                                                                       
|5003 |      FAST DUAL       |          |      1 |      1 |      1 |00:00:00.01 |       0 |       |       |          |                                                                                                                                                                                       
|5004 |      FAST DUAL       |          |      1 |      1 |      1 |00:00:00.01 |       0 |       |       |          |                                                                                                                                                                                       
|5005 |   TABLE ACCESS FULL  | TABLE123 |      1 |   9999 |   9999 |00:00:00.02 |      29 |       |       |          |                                                                                                                                                                                       
---------------------------------------------------------------------------------------------------------------------- 
于 2013-10-21T16:11:13.663 回答