SQL IN Clause 1000 item limit

前端 未结 4 1677
梦毁少年i
梦毁少年i 2020-11-22 11:19

It is possible to put more than 1000 items in the SQL IN clause? We have been getting issues with our Oracle database not being able to handle it.

IF yes, how do we

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 12:14

    You should transform the IN clauses to INNER JOIN clauses.

    You can transform a query like this one

    SELECT  foo   
    FROM    bar   
    WHERE bar.stuff IN  
           (SELECT  stuff FROM asdf)
    

    in a query like this other one.

    SELECT  b.foo 
    FROM    ( 
            SELECT  DISTINCT stuff 
            FROM    asdf ) a 
    JOIN    bar b 
    ON      b.stuff = a.stuff
    

    You will also gain a lot of performance

提交回复
热议问题