Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why oracle IN clause has limit of 1000 only for static data?

Oracle IN clause has limit of 1000 for static data,but it accepts unlimited data from sub queries. why?

like image 442
Vivek Baranwal Avatar asked Sep 25 '13 10:09

Vivek Baranwal


People also ask

Does in clause have limits in Oracle?

In Oracle we can only put up to 1000 values into an IN clause.

How do you increase maximum number of expressions in a list is 1000 in Oracle?

Root Cause: Oracle IN / OR list has limit of 1000 (actually its 999) number of expression/value list. Proposed Solution: You need to split the list of expressions into multiple sets (using OR) and each should be less than 1000 list/expressoin combine using IN / Or list.


1 Answers

It's a restriction on any expression list:

A comma-delimited list of expressions can contain no more than 1000 expressions.

Why 1000? Presumably the implementation needs some kind of limit, and that probably seemed like more than enough. There may well be, or certainly may have been when that limit was set decades ago, a performance reason for the limit as well, particularly as the IN is converted to multiple OR statements by the optimiser in this case (which you can see if you look at the execution plan).

I'd struggle to come up with a reasonable scenario that needed to get anywhere near that, with fixed values that couldn't be derived from other data anyway as a subquery.

I suspect it's somewhat related to the logical database limits which say you can't have more than 1000 columns in a table, for instance; since an expression list is used in an insert statement to list both the columns and the values being inserted, the expression list has to be able to match that, but maybe has no reason to exceed it.

Speculation of course... without seeing the internals of the software you're unlikely to get a definitive answer.

like image 101
Alex Poole Avatar answered Sep 30 '22 14:09

Alex Poole