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

  • Home
  • SEARCH
  • 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 41741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:13:44+00:00 2026-05-10T15:13:44+00:00

It’s my understanding that nulls are not indexable in DB2, so assuming we have

  • 0

It’s my understanding that nulls are not indexable in DB2, so assuming we have a huge table (Sales) with a date column (sold_on) which is normally a date, but is occasionally (10% of the time) null.

Furthermore, let’s assume that it’s a legacy application that we can’t change, so those nulls are staying there and mean something (let’s say sales that were returned).

We can make the following query fast by putting an index on the sold_on and total columns

Select * from Sales  where  Sales.sold_on between date1 and date2 and Sales.total = 9.99 

But an index won’t make this query any faster:

Select * from Sales  where  Sales.sold_on is null and Sales.total = 9.99 

Because the indexing is done on the value.

Can I index nulls? Maybe by changing the index type? Indexing the indicator column?

  • 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. 2026-05-10T15:13:44+00:00Added an answer on May 10, 2026 at 3:13 pm

    I’m no DB2 expert, but if 10% of your values are null, I don’t think an index on that column alone will ever help your query. 10% is too many to bother using an index for — it’ll just do a table scan. If you were talking about 2-3%, I think it would actually use your index.

    Think about how many records are on a page/block — say 20. The reason to use an index is to avoid fetching pages you don’t need. The odds that a given page will contain 0 records that are null is (90%)^20, or 12%. Those aren’t good odds — you’re going to need 88% of your pages to be fetched anyway, using the index isn’t very helpful.

    If, however, your select clause only included a few columns (and not *) — say just salesid, you could probably get it to use an index on (sold_on,salesid), as the read of the data page wouldn’t be needed — all the data would be in the index.

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

Sidebar

Ask A Question

Stats

  • Questions 51k
  • Answers 51k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You'll have to call the win32 API: WNetGetUniversalName May 11, 2026 at 6:28 am
  • added an answer With CSS3, you should be able to accomplish this with… May 11, 2026 at 6:28 am
  • added an answer Programatic Method To register button press events you can either… May 11, 2026 at 6:28 am

Top Members

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

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.