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 3951498
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:44:16+00:00 2026-05-20T01:44:16+00:00

What I want to achieve is: Provide a mechanism for batch selects ( select

  • 0

What I want to achieve is:

  • Provide a mechanism for batch selects (select * from users where user_id in (?, ?, ?, ?, ?)). Batch size is 5 in this e.g.
  • Use bind variables and maintain consistent sized batches

So if the application requires Users for 8 different user_id then I would call the aforementioned SQL twice having 5 params in each call (rather than one call with 5 user_ids and then with 3).

So, I need to pad the user_ids if the input size is less than the batch size. I wanted to know what would be a good padding scheme in terms of performance:

  • Using null?
  • Using the first user_id

When using null would there be any performance degradation if the column is NULLABLE?
Also when using null would the DB still come up with one query plan, because that’s what I want to achieve using consistent sized batches?

  • 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-20T01:44:16+00:00Added an answer on May 20, 2026 at 1:44 am

    Both of your options are equivalent*.

    * Using null?
    * Using the first user_id
    

    There is no difference*. In an IN clause, NULLs are removed, so there is no performance degradation, UNLESS the RDBMS you are using has an ANSI_NULLS option that you can set to OFF (e.g. SQL Server) – see far below. In CLAUSES are also SETs, so having (1,2,3,1,1) is equivalent to only having (1,2,3) but it does make your binding easier.

    So if you are (1) using a RDBMS that allows for NULLs to match NULLs and (2) you plan to use that setting, the 2 are equivalent.

    On the other hand, to be 100% certain, just use the 2nd option.


    SQL Server code showing NULL picking out NULLs.

    set ansi_nulls off
    select *
    from (select 1 a union all select 2 union all select null) x
    where a in (1,2, null)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to achieve something like this in C# 3.5: public void Register<T>() :
I want to achieve something like this inside a UIView: I have created a
I want to achieve the functionality that this editor has got with its preview
I want to achieve this using html and css: I have tried to set
I want to achieve this: private static InputStream getTokenCfg() { String cfg = MessageFormat.format(
I want to achieve the Re-size,Clone,Drag/Drop and rotate functionality on an image selected by
I want to achieve rounded corners for the tab that I've constructed in my
I want to achieve the following: ID | Counter ------------ 0 | 343 1
I want to achieve the effect of a 2D image I have but a
I want to achieve something like the following: UrlBuilder ub = new UrlBuilder(http://www.google.com/search); ub.Parameters.Add(q,request);

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.