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»»

Query Cost 27% Expand / Collapse
Author
Message
Posted Tuesday, May 15, 2012 1:08 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, August 12, 2014 10:36 PM
Points: 27, Visits: 287
How to change non clustered index scan to non clustered index seek?The concerned tables already have non clustered index configured.
Post #1300530
Posted Tuesday, May 15, 2012 1:44 PM


SSC-Insane

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

Group: General Forum Members
Last Login: Today @ 10:16 AM
Points: 20,860, Visits: 32,884
Alone (5/15/2012)
How to change non clustered index scan to non clustered index seek?The concerned tables already have non clustered index configured.


I have no idea based solely on what you have posted. With no information regarding the query, table or tables involved, the indexes defined, or the actual execution plan all you are going to get is ignored or wild shots in the dark that may not even be useful.



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 #1300564
Posted Tuesday, May 15, 2012 2:03 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Yesterday @ 8:36 AM
Points: 40,615, Visits: 37,080
Please post query, execution plan, table definition, index definition.

Also, ask yourself if the scan is a problem before you spend any time thinking about it.
http://sqlinthewild.co.za/index.php/2010/03/11/the-root-of-all-evil/



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 #1300579
Posted Tuesday, May 15, 2012 2:05 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, December 15, 2014 2:26 PM
Points: 5,466, Visits: 7,647
Alone (5/15/2012)
How to change non clustered index scan to non clustered index seek?The concerned tables already have non clustered index configured.


Typically? You don't. A seek happens when the data and the filter are selective enough. To get close to guaranteeing a seek you'd need a filter roughly on par with a single day in a year, with even distribution. Even then it would depend on how the index is setup and what your where clause looked like.

After that you're dealing with data volume and tipping points and row width and a number of other factors.

Schema, Actual Execution Plan, and the T-SQL would help us help you here.



- Craig Farrell

Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

For better assistance in answering your questions | Forum Netiquette
For index/tuning help, follow these directions. |Tally Tables

Twitter: @AnyWayDBA
Post #1300581
Posted Tuesday, May 15, 2012 8:02 PM


SSC-Dedicated

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

Group: General Forum Members
Last Login: Yesterday @ 7:27 AM
Points: 35,769, Visits: 32,437
Evil Kraig F (5/15/2012)
Alone (5/15/2012)
How to change non clustered index scan to non clustered index seek?The concerned tables already have non clustered index configured.


Typically? You don't. A seek happens when the data and the filter are selective enough. To get close to guaranteeing a seek you'd need a filter roughly on par with a single day in a year, with even distribution. Even then it would depend on how the index is setup and what your where clause looked like.

After that you're dealing with data volume and tipping points and row width and a number of other factors.

Schema, Actual Execution Plan, and the T-SQL would help us help you here.


Gosh... if all that were true, it wouldn't be worth having things like calendar tables.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1300725
Posted Tuesday, May 15, 2012 8:10 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 3:20 PM
Points: 18,064, Visits: 16,099
GilaMonster (5/15/2012)


Also, ask yourself if the scan is a problem before you spend any time thinking about it.


+1




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


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #1300731
Posted Wednesday, May 16, 2012 3:17 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, December 15, 2014 2:26 PM
Points: 5,466, Visits: 7,647
Jeff Moden (5/15/2012)

Gosh... if all that were true, it wouldn't be worth having things like calendar tables.


Alright, I'll bite into that one... there's nothing in there I see as being inaccurate, how did a calendar table get involved?

The only piece of that which is a generality is the 1 day in a year bit for seek vs. scan guarantees, and perhaps I should have been more clear. 0.03 is the 'near guarantee' mark, which is roughly 1/300... for round numbers I use one day in a year. It CAN scan before than, but you're not guaranteed.



- Craig Farrell

Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

For better assistance in answering your questions | Forum Netiquette
For index/tuning help, follow these directions. |Tally Tables

Twitter: @AnyWayDBA
Post #1301392
Posted Wednesday, May 16, 2012 8:00 PM


SSC-Dedicated

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

Group: General Forum Members
Last Login: Yesterday @ 7:27 AM
Points: 35,769, Visits: 32,437
Evil Kraig F (5/16/2012)
Jeff Moden (5/15/2012)

Gosh... if all that were true, it wouldn't be worth having things like calendar tables.


Alright, I'll bite into that one... there's nothing in there I see as being inaccurate, how did a calendar table get involved?

The only piece of that which is a generality is the 1 day in a year bit for seek vs. scan guarantees, and perhaps I should have been more clear. 0.03 is the 'near guarantee' mark, which is roughly 1/300... for round numbers I use one day in a year. It CAN scan before than, but you're not guaranteed.


Are you suggesting that if I use something like a tenth of a table that a scan is virtually guaranteed?


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1301459
Posted Thursday, May 17, 2012 12:36 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Yesterday @ 8:36 AM
Points: 40,615, Visits: 37,080
Jeff Moden (5/16/2012)
Are you suggesting that if I use something like a tenth of a table that a scan is virtually guaranteed?


If you are using a non-covering index, then absolutely yes. The tipping point (where using a noncovering index and doing key lookups is less efficient than a table scan) is somewhere around 0.5% of the total rows in the table (it's ~ number of rows = 30% of the number of pages in the table)

There's a post on my blog "Seek or Scan" which shows this. Sorry, don't have time to find it, got to get to class.



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 #1301509
Posted Thursday, May 17, 2012 4:26 AM


SSC-Dedicated

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

Group: General Forum Members
Last Login: Yesterday @ 7:27 AM
Points: 35,769, Visits: 32,437
Thanks, folks... I'll take a deeper look.

--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1301622
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse