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

Stairway to SQL Server Indexes: Step 2, Deeper into Nonclustered Indexes Expand / Collapse
Author
Message
Posted Monday, February 14, 2011 10:37 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Saturday, June 23, 2012 10:54 AM
Points: 8, Visits: 23
Comments posted to this topic are about the item Stairway to SQL Server Indexes: Step 2, Deeper into Nonclustered Indexes
Post #1063677
Posted Friday, February 25, 2011 5:37 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, December 2, 2014 3:15 PM
Points: 70, Visits: 233
I think the line that reads 'scanning the entire table of one million rows' should probably be 'scanning the entire table of twenty thousand odd rows'.

I'm not being pedantic here - I always like it when someone questions something in a doc I've written as it shows they've read it. The only reason I noticed it was such a good article that I was paying proper attention when I read it :).

Thanks for this series, I'm really enjoying it.

I'm meant to be a seasoned DBA, sometimes it worries me how rusty I am on some very fundamental subjects.

Best,

Andy




Post #1069528
Posted Tuesday, May 24, 2011 12:18 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Saturday, June 23, 2012 10:54 AM
Points: 8, Visits: 23
Andy,

Sorry for the long delay in replying; have been completing the remaining levels.

Will reread the level with an eye of rewording it.

Thanks for the input,
Dave Durant.
Author.
Post #1114303
Posted Saturday, March 17, 2012 11:28 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Sunday, December 14, 2014 10:08 AM
Points: 93, Visits: 342
Hi David,

One quick one. In session II of Stairway to SQL Server Indexes you mentioned that:

* Non Clustered Index Is a sorted set of entries.

I have little doubt on it.

If we run below query you will find that the output of first query on "CONTACTS_INDEX" table with "FULLNAME" index on "LastName, FirstName" the out put is not sorted.

SELECT * FROM DBO.CONTACTS_INDEX WHERE LASTNAME LIKE 'Ste%'

But when we run the below query on "CONTACT_NOINDEX" table results are sorted.

SELECT * FROM DBO.CONTACTS_NOINDEX WHERE LASTNAME LIKE 'Ste%'


So now my question is why is it so? If I do a select on Heap table I am getting data sorted but when I do a select on table with NonCluster index data is not sorted.

Post #1268664
Posted Monday, October 22, 2012 10:22 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, October 9, 2014 9:54 AM
Points: 2, Visits: 91
Dave,

Really benefiting from this series, in fact, all stairway series.

I have a very beginner-level question, you're showing the contents of the indexes as if selecting from a table. Is there a way to actually do it. I mean like "select * from ix_table1_nc_index"... is there a way to do that?

Thanks,
Faraz
Post #1375592
Posted Wednesday, November 26, 2014 12:48 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, December 17, 2014 11:09 PM
Points: 426, Visits: 540
Hi Faraz,

you can use DBCC IND if you use SQL Server < 2012 or sys.dm_db_database_page_allocation for SQL Server >= 2012.
This will give you a list of allocated pages.
To have a look at the root node (or any other page of the index you use

DBCC PAGE

More details about can be found here:
http://blogs.msdn.com/b/sqlserverstorageengine/archive/2006/12/13/more-undocumented-fun_3a00_-dbcc-ind_2c00_-dbcc-page_2c00_-and-off_2d00_row-columns.aspx


Microsoft Certified Master: SQL Server 2008
my blog: http://db-berater.blogspot.de (german only!)
Post #1639184
Posted Wednesday, November 26, 2014 4:22 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 2:15 AM
Points: 5,317, Visits: 12,354
Uwe Ricken (11/26/2014)
Hi Faraz,

you can use DBCC IND if you use SQL Server < 2012 or sys.dm_db_database_page_allocation for SQL Server >= 2012.
This will give you a list of allocated pages.
To have a look at the root node (or any other page of the index you use

DBCC PAGE

More details about can be found here:
http://blogs.msdn.com/b/sqlserverstorageengine/archive/2006/12/13/more-undocumented-fun_3a00_-dbcc-ind_2c00_-dbcc-page_2c00_-and-off_2d00_row-columns.aspx


Helpful as this response may be, it does not answer Faraz' question.



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.

It is better to keep your mouth shut and appear stupid than to open it and remove all doubt. (Mark Twain)
Post #1639267
Posted Wednesday, November 26, 2014 4:38 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Wednesday, December 17, 2014 11:09 PM
Points: 426, Visits: 540
Hey Phil,

why doesn't it meet the requirements / question?
He wants to have the content of the index itself or do I missunderstand the request?

CREATE TABLE dbo.foo
(
id INT NOT NULL,
c1 CHAR(20) NOT NULL,
c2 DATE NOT NULL,

CONSTRAINT pk_foo_id PRIMARY KEY CLUSTERED (Id)
);
GO

INSERT INTO dbo.foo (id, c1, c2) VALUES
(1, 'col1', '20140101'),
(2, 'col2', '20140201'),
(3, 'col3', '20140301'),
(4, 'col4', '20140401')
GO

CREATE NONCLUSTERED INDEX ix_foo_c2 ON dbo.foo(c2);
GO

-- check the index id's of dbo.foo
SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID('dbo.foo');
GO

-- IF nonclustered index is ID = 2
DBCC IND('demo', 'dbo.foo', 2);

-- Output of page content to client
-- after execution of DBCC IND the page with type = 2 is
-- the index page! 10 is IAM!
-- Replace the page_id with that evaluated id
DBCC TRACEON (3604);
DBCC PAGE('demo', 1, <page_id, 3);
GO

When running this script you get the list of values from one page of the index with its content!
BTW: The question was from 2012 :)
Seems to be worthless to discuss the intention :)


Microsoft Certified Master: SQL Server 2008
my blog: http://db-berater.blogspot.de (german only!)
Post #1639270
Posted Wednesday, November 26, 2014 5:06 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 2:15 AM
Points: 5,317, Visits: 12,354
why doesn't it meet the requirements / question?
He wants to have the content of the index itself or do I missunderstand the request?


Because I believe the poster was asking whether the actual physical data could be returned by selecting from the index, not the index meta data.



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.

It is better to keep your mouth shut and appear stupid than to open it and remove all doubt. (Mark Twain)
Post #1639283
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse