PostgreSQL - max number of parameters in “IN” clause?

后端 未结 8 1283
無奈伤痛
無奈伤痛 2020-11-28 21:58

In Postgres, you can specify an IN clause, like this:

SELECT * FROM user WHERE id IN (1000, 1001, 1002)

Does anyone know what\'s the maximu

8条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 22:35

    This is not really an answer to the present question, however it might help others too.

    At least I can tell there is a technical limit of 32767 values (=Short.MAX_VALUE) passable to the PostgreSQL backend, using Posgresql's JDBC driver 9.1.

    This is a test of "delete from x where id in (... 100k values...)" with the postgresql jdbc driver:

    Caused by: java.io.IOException: Tried to send an out-of-range integer as a 2-byte value: 100000
        at org.postgresql.core.PGStream.SendInteger2(PGStream.java:201)
    

提交回复
热议问题