Be Careful When Using (IN) Keyword

Standard

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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s