Subject | Re: [firebird-support] The known limit (1499) in IN clause |
---|---|
Author | Arno Brinkman |
Post date | 2008-07-03T07:42:25Z |
Hi,
SELECT * FROM <table>
WHERE
ID IN ( 1, 2, 3, ..., 1499 )
OR
ID IN ( 1500, 1501, 1502, ..., 2998 )
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database with many powerful SQL features:
http://www.firebirdsql.org
http://www.firebirdsql.info
General database developer support:
http://www.databasedevelopmentforum.com
Support list for Interbase and Firebird users:
firebird-support@yahoogroups.com
Nederlandse firebird nieuwsgroep:
news://newsgroups.firebirdsql.info
> So, what is the recommended workaround for this limit (e.g. in termsCombine the IN lists with OR, but you could finally still hit the SQL text (or BLR) limit.
> of performance)?
>
> A) Store IDs into a temporary table and use that table in an IN
> clause.
>
> SELECT *
> FROM <table>
> WHERE ID IN ( SELECT ID FROM <temporary_table> )
>
> B) Execute multiple queries, each having maximally 1499 elements in
> an IN list, and then combine the results.
>
> SELECT *
> FROM <table>
> WHERE ID IN ( 1, 2, 3, ..., 1499 )
>
> combined with
>
> SELECT *
> FROM <table>
> WHERE ID IN ( 1500, 1501, 1502, ..., 2998 )
>
> Other solutions?
SELECT * FROM <table>
WHERE
ID IN ( 1, 2, 3, ..., 1499 )
OR
ID IN ( 1500, 1501, 1502, ..., 2998 )
Regards,
Arno Brinkman
ABVisie
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird open source database with many powerful SQL features:
http://www.firebirdsql.org
http://www.firebirdsql.info
General database developer support:
http://www.databasedevelopmentforum.com
Support list for Interbase and Firebird users:
firebird-support@yahoogroups.com
Nederlandse firebird nieuwsgroep:
news://newsgroups.firebirdsql.info