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

后端 未结 8 1297
無奈伤痛
無奈伤痛 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:32

    If you have query like:

    SELECT * FROM user WHERE id IN (1, 2, 3, 4 -- and thousands of another keys)
    

    you may increase performace if rewrite your query like:

    SELECT * FROM user WHERE id = ANY(VALUES (1), (2), (3), (4) -- and thousands of another keys)
    

提交回复
热议问题