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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:34:43+00:00 2026-06-12T01:34:43+00:00

So, we have a table, InventoryListItems , that has several columns. Because we’re going

  • 0

So, we have a table, InventoryListItems, that has several columns. Because we’re going to be looking for rows at times based on a particlar column (g_list_id, a foreign key), we have that foreign key column placed into a non-clustered index we’ll call MYINDEX.

So when I search for data like this:

-- fake data for example
DECLARE @ListId uniqueidentifier
SELECT @ListId = '7BCD0E9F-28D9-4F40-BD67-803005179B04' 

SELECT *
FROM [dbo].[InventoryListItems]
WHERE [g_list_id] = @ListId

I expected that it would use the MYINDEX index to find just the needed rows, and then look up the information in those rows. So not as good as just finding everything we need in the index itself, but still a big win over doing a full scan of the table.

But instead it seems that I’m still getting a clustered index scan. I can’t figure out why that would happen.

If I do something like SELECTing only the values in the included columns of the index, it does what I would expect, an index seek, and just pulls everything from the index.

But if I SELECT *, why does it just bail on the index and do a scan when it seems like it would still benefit greatly from using it because it’s referenced in the WHERE clause?

  • 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-06-12T01:34:44+00:00Added an answer on June 12, 2026 at 1:34 am

    Since you’re doing a SELECT * and thus you retrieve all columns, SQL Server’s query optimizer may have decided it’s easier and more efficient to just do a clustered index scan – since it needs to go to the clustered index leaf level to get all the columns anyway (and doing a seek first, and then a key lookup to actually get the whole data page, is quite an expensive operation – scan might just be more efficient in this setup).

    I’m almost sure if you try

    SELECT g_list_id
    FROM [dbo].[InventoryListItems]
    WHERE [g_list_id] = @ListId
    

    then there will be an index seek instead (since you’re only retrieving a single column – not everything).

    That’s one of the reasons why I would recommend to be extra careful when using SELECT * .... – try to avoid it if ever possible.

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

Sidebar

Related Questions

I have table with around 70 000 rows. There is 6000 rows that i
I have table that contains more than 12 millions of rows. I need to
I have table in MS Access that has an AutoNumber type in field ID
I have table inside a div tab. The table has 40 rows in it
I have table with permissions that has few bit fields. I want to group
I have table in which I am inserting rows for employee but next time
I have table of data that is sorted as follows: Item | Sample |
I have table with column Percentage varchar(10) Data in that table is Pecentage 2/10
I have table with two columns (varchar from, varchar to). This table represents connections
I have table with 5 columns ------------------------------------------------------ |_id(mongo default)| link | name| street|zip |

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.