Be Careful When Using (IN) Keyword


In a some tasks you have to write a SQL statment has a condition like x must be one of the following values {1,2,3, …..}. you can do this by using (in) keyword, and it will give you a good results, However if this values is calculated dynamically your statment may fail in unexpect case.

There is a limitation on this list of values and if these values exceed this limit of values, your statment will fails and may cause a disaster at the production level

This is exactly happened with me in a service which get a data from the database and sends an SMSs according to this data, because we were execute the database operation as a bulk update statement to get a better performance than update each record individually. Under high load this statements fails because of its long length. This cause a SMS which represented by a record in a database still has a status (not sent) and sends again and again