Page 1 of 1

Maximum length of the SQL-statment

Posted: Thu 23 Oct 2014 16:09
by GVCL
Hi,

how long in characters can a SQL-statement be using IBDAC components? I could not find any restrictions mentioned somewhere, but I am sure there are some :wink:

I want to use a SELECT * FROM ANYTAB WHERE ANYID IN (100,234,345...) with may be hundreds or even thousands of items. Would that be possible?

A BETWEEN or similar would not work as i.e. the IDs are randomly distributed and are not sequential.

Any hint welcome!

Re: Maximum length of the SQL-statment

Posted: Thu 23 Oct 2014 21:34
by abak
Hi GVCL,

Don't use "in" statment in your select query : depreciated and slow !
You can get around by :
- creating a second table Table2
- insert your thounsand ID in this table
- then, join it to your table :
_______________________________________________
Select T1.field1, T1.field2, ...
From myTable T1 Join Table2 T2 on T1.ID = T2.ID
_______________________________________________

The Table2 has 2 fields : its autoincrement key ID2 and your field ID (wanted)
ID2 ID
1 185
2 983
3 1097

And to go fast, you can create an index for the ID field in table2 :
CREATE [ASC[ENDING] | [DESC[ENDING]] INDEX indexname
ON table2 ID

Best regards.

Re: Maximum length of the SQL-statment

Posted: Fri 24 Oct 2014 08:16
by ViktorV
Firebird applies a limit of 64KB (65536 characters in a single-byte character set) to the SQL statement.