0

I want to query data for a set of IDs from a table. The size of the set might become large in some cases, for around 1000 to 4000 IDs.

Ex1: SELECT x FROM table WHERE id IN (ID1, ID2, ..., ID4000)

Ex2: SELECT x FROM table WHERE id = ID1 OR id = ID2 ... OR id =ID4000

1- Whats the limitation of including such a set in the query's WHERE clause (OR or IN statement)?

2- Is there a drawback or is that size considered large?

3- Is splitting the query to smaller portions the alternative?

Zay
  • 105
  • 1
  • 9

1 Answers1

0

This link below will help you to think which is better to use.

Maybe, first of all, you should tell me what database you Are using.


MySQL :
IN vs OR in the SQL WHERE Clause

SQL Server :
SQL Server: Select in vs or?

PostgreSQL :
https://www.postgresql.org/message-id/8078a1730712121530r70a520e1qf9c09b516db54b0e%40mail.gmail.com

Sherly Febrianti
  • 1,052
  • 14
  • 30