Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4622444
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:50:39+00:00 2026-05-22T02:50:39+00:00

Should I be concerned about IN expressions with hundreds of values in the array?

  • 0

Should I be concerned about IN expressions with hundreds of values in the array? For example:

myCriteria.Add(Restrictions.In("Id", myArrayOfHundredsOfItems);

Which results in the sql:

select * from MyTable where Id in (1,2,3,4, ...etc .. 900)

MSDN says “Including an extremely large number of values (many thousands) in an IN clause can consume resources and return errors 8623 or 8632.”

OK, so ‘many thousands’ is out of the question. Is there any reason to avoid an array of maybe a few hundred item?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:50:40+00:00Added an answer on May 22, 2026 at 2:50 am

    There is another limit. The values in the IN clause are passed as single parameters. There is a limit of parameters. It is probably the same as for stored procedures which is 2100.

    I have a similar situation where I pass a large amount of Guids. I split it up in several queries, each of them getting up to 1000 parameters. The queries are executed as multi criteria in a batch, so there is only a single database roundtrip.

    Performance may suffer when using IN compared to joins. In my scenario I don’t have any performance issues because of that. If you don’t have that many parameters, it most probably won’t be an issue for you.

    By the way, getting objects by id could also be implemented by:

    • Get<Entit>(id), which requires a single query, but only when the entity isn’t in the cache yet.
    • Load<Entity>(id), which creates a proxy if the entity isn’t in cache and only loads in when accessing properties. It most probably makes us of batch-size and loads several instances at once (pre-fetching).

    Unfortunately, there isn’t a future-get.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a rather large flash project and so I'm concerned about memory usage.
Apart from performance concerns, should web-based applications be built differently according to the number
Should I start with Django or JavaScript?
Should the folders in a solution match the namespace? In one of my teams
Should you set all the objects to null ( Nothing in VB.NET) once you
Should I still be using tables anyway? The table code I'd be replacing is:
Should I use Named Pipes, or .NET Remoting to communicate with a running process
Should you ever use protected member variables? What are the the advantages and what
Should developers avoid using continue in C# or its equivalent in other languages to
Should I catch exceptions for logging purposes? public foo(..) { try { ... }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.