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
  • 115
  • 1
  • 9
  • The answer is implementation defined. Which dbms are you using? – jarlh Oct 19 '17 at 11:40
  • Such limits depend on the database you are using. – Gordon Linoff Oct 19 '17 at 11:43
  • Which [DBMS](https://en.wikipedia.org/wiki/DBMS) product are you using? Postgres? Oracle? "_SQL_" is just a query language, not the name of a specific database product. –  Oct 19 '17 at 11:50

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,097
  • 15
  • 33