We help IT Professionals succeed at work.

Constant Scan

Last Modified: 2012-06-27
I have a simple select, something like this:

SELECT Column1, Column2, Column3, Column4, Column5, Column6, Column7, Column8, Column9
FROM Table1 T1
    INNER JOIN Table2 T2 on T1.Column20 = T2.Column1
WHERE T1.Column10 = @Col10
     AND T1.Column11 = @Col11
     AND T1.Column12 = @Col12
     AND T1.Column13 = @Col13
     AND T1.Column14 = @Col14
     AND ISNULL(T1.Column15) = ISNULL(@Col15,0)

clustered index n T2.column1
nonclustered index on T1.Column20
nonclustered index on T1.Column10

I keep getting Constant Scan. The Execution Plan looks something like:

SELECT (Cost: 0%) <-------------------- Constatn Scan (Cost: 100%)

I notice one thing though, the T1.Column11 pass in value is NULL. If I remove that WHERE condition line (AND T1.Column11 = @Col11), then I will get the usual execution plan of Index Seek, KeyLookup, Nested Loops, etc -- which is pretty accetable.

T1.Column11 is non nullable but somewhere we pass in NULL value but sometimes we pass in some value too.

Why am I getting constant scan with that candition? I read and read and read about constant scan, but couldn't really grasp what was that. I don't think my ISNULL function on my WHERE condition is the culprit to the constant scan, i am sure it's the NULL value pass in to T1.Column11.

Any suggestions and advice  are greatly appreciated, Thanks!

Watch Question

Expert of the Quarter 2010
Expert of the Year 2010
This one is on us!
(Get your first solution completely free - no credit card required)
Faiga DiegelSr Database Engineer


You're great! Thanks!

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.