Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Is it possible to create nonclustered index on columns with space and ignore the space so that it does not do a table scan? Expand / Collapse
Author
Message
Posted Friday, December 18, 2009 10:02 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, August 12, 2010 10:47 AM
Points: 24, Visits: 58
Is it possible to create nonclustered index on columns with space and ignore the space so that it does not do a table scan?

Thank You

SD Khan
Post #836456
Posted Friday, December 18, 2009 10:16 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 5:20 PM
Points: 17,600, Visits: 15,462
The table scan occurs if the Engine determines that a table scan will be more efficient. If you have null values or empty strings in your column, they will be included in your non-clustered index if you create it.

You should test the creation of your non-clustered index to determine if the new index will help improve performance. One of the factors to consider is column selectivity and uniqueness of the data in that column. The query that is causing the table-scan may also need to be revised.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #836467
Posted Friday, December 18, 2009 10:25 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: 2 days ago @ 3:43 PM
Points: 39,866, Visits: 36,206
What precisely do you mean by "columns with space"?
Columns with lots of nulls?
Columns with lots of empty strings?
Columns that have varchar/nvarchar with leading/trailing spaces?
Something else?



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #836479
Posted Friday, December 18, 2009 10:31 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, August 12, 2010 10:47 AM
Points: 24, Visits: 58
I am not sure what the developer is actually trying to achive so i told him to redo his query.....but is it possible to do teh create index in a way so that it ignores the blank spaces?
I think the problem is there has been new fields added and new data is coming in in the table.

Thank you
Post #836485
Posted Friday, December 18, 2009 10:35 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 10:01 AM
Points: 3,840, Visits: 3,841
Who designed the tables, the developer? If you post the table DDL, index definitions, sample data and your query, we can help more. Please reference this link to learn how to format your sample content:

http://www.sqlservercentral.com/articles/Best+Practices/61537/




John Rowan

======================================================
======================================================
Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
Post #836490
Posted Friday, December 18, 2009 10:52 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: 2 days ago @ 3:43 PM
Points: 39,866, Visits: 36,206
skhan-680833 (12/18/2009)
but is it possible to do teh create index in a way so that it ignores the blank spaces?


What do you mean? What blank spaces where?



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #836500
Posted Friday, December 18, 2009 10:54 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:08 PM
Points: 20,676, Visits: 32,266
GilaMonster (12/18/2009)
skhan-680833 (12/18/2009)
but is it possible to do teh create index in a way so that it ignores the blank spaces?


What do you mean? What blank spaces where?


Almost sounds like a filtered index. Unfortunately, not available in SQL Server 2005.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #836502
Posted Friday, December 18, 2009 11:59 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 5:20 PM
Points: 17,600, Visits: 15,462
More information would be needed to best answer the question. As it is, we are only guessing at how best to help/answer your question.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #836553
Posted Friday, December 18, 2009 12:05 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, August 12, 2010 10:47 AM
Points: 24, Visits: 58
Thanks everyone. I have asked the developer to redo the query. I do not think filtered index is an option and as it is a vendor apps they build these indexes thourgh the vendor designer tools. Also I checked a few things and I think he should not put indexes on those columns and do the query in a different way. Thank you for all of your help and suggestions.

SD Khan
Post #836560
Posted Friday, December 18, 2009 12:57 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 5:20 PM
Points: 17,600, Visits: 15,462
You're welcome.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #836599
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse