Is PostgreSQL IN () message still fast with up to 1000 arguments?

I am requesting to return all rows from a table except those that are in some list of values ​​that are constant at the time of the query. For instance. SELECT * FROM table WHERE id IN (%), and% is guaranteed to be a list of values, not a subquery. However, in some cases, this list of values ​​can be up to 1000 elements. Should I limit this to a smaller sublist (only 50-100 items as low as I can go, in this case) or will there be a slight increase in performance?

+3
source share
2 answers

I assume this is a large table, otherwise it would not make much difference.

. IN, Postgres . , .

WHERE, :

select * from table where id in (%) and my_date > '2010-01-01';

, , (my_date) , .

JOIN , . - ( ), /.

, :

  • IN.
  • , . IN , , , .
+4

JOIN, . IN(), 1000 , .

+2

Source: https://habr.com/ru/post/1757875/


All Articles