March 15, 2017 at 3:12 pm
When and how do you use a covering Index?
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 15, 2017 at 3:13 pm
Is there anything different about scripting out a coverard index?
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 15, 2017 at 3:40 pm
First question, in your own words, what is a covering index?
As far as scripting out a covering index, you do it the same way you do any other index.
March 15, 2017 at 3:43 pm
A covering index is an index that has all the columns needed to satisfy, or "cover", a given query.
For example, say I have a table with 20 columns, col1 thru col20.
clustered on col1 (ix1)
nonclustered index on ( col2 ) (ix2)
If I write this query:
SELECT col2, col1
FROM table_name
ORDER BY col2
Index ix2 is a perfect covering index, because it has all the columns needed to satisfy the query (the clus column(s) are always included in every index, so col1 is present also).
If you wrote this query:
SELECT col2, col1, col3
FROM table_name
ORDER BY col2
Only the clustering index covers this query, so SQL would have to scan the whole table.
If you modified IX2 to be:
nonclustered index on ( col2 ) include ( col3)
Then ix2 would again cover the query.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
March 15, 2017 at 4:03 pm
Welsh Corgi - Wednesday, March 15, 2017 3:13 PMIs there anything different about scripting out a coverard index?
That is what I thought.
Make sure the scriptoption is set to true
You can easily script theindex by using Object Explorer ->Databases -> Database -> Tables - > Indexes -> right-click on index- > Create Script
Thanks.
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 15, 2017 at 5:28 pm
ScottPletcher - Wednesday, March 15, 2017 3:43 PMA covering index is an index that has all the columns needed to satisfy, or "cover", a given query.For example, say I have a table with 20 columns, col1 thru col20.
clustered on col1 (ix1)
nonclustered index on ( col2 ) (ix2)If I write this query:
SELECT col2, col1
FROM table_name
ORDER BY col2
Index ix2 is a perfect covering index, because it has all the columns needed to satisfy the query (the clus column(s) are always included in every index, so col1 is present also).If you wrote this query:
SELECT col2, col1, col3
FROM table_name
ORDER BY col2
Only the clustering index covers this query, so SQL would have to scan the whole table.If you modified IX2 to be:
nonclustered index on ( col2 ) include ( col3)
Then ix2 would again cover the query.
Scott, I wasn't asking you, that question was for the OP. I wanted to see if he understood what a covering index was.
March 15, 2017 at 5:39 pm
Welsh Corgi - Wednesday, March 15, 2017 4:03 PMWelsh Corgi - Wednesday, March 15, 2017 3:13 PMIs there anything different about scripting out a coverard index?That is what I thought.
Make sure the scriptoption is set to true
You can easily script theindex by using Object Explorer ->Databases -> Database -> Tables - > Indexes -> right-click on index- > Create Script
Thanks.
Welsh Corgi - Wednesday, March 15, 2017 4:03 PMWelsh Corgi - Wednesday, March 15, 2017 3:13 PMIs there anything different about scripting out a coverard index?That is what I thought.
Make sure the scriptoption is set to true
You can easily script theindex by using Object Explorer ->Databases -> Database -> Tables - > Indexes -> right-click on index- > Create Script
Thanks.
Lynn,
I know what a covering index is.
I wanted to make sure all bases are covered.
You want to make sure I know what a covering index is? lol
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 15, 2017 at 5:41 pm
Thanks for your input.
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 15, 2017 at 5:45 pm
I just wanted to articulate it properly.
Are you testing me? lol
Thank you.
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 15, 2017 at 5:47 pm
Lynn Pettis - Wednesday, March 15, 2017 5:28 PMScottPletcher - Wednesday, March 15, 2017 3:43 PMA covering index is an index that has all the columns needed to satisfy, or "cover", a given query.For example, say I have a table with 20 columns, col1 thru col20.
clustered on col1 (ix1)
nonclustered index on ( col2 ) (ix2)If I write this query:
SELECT col2, col1
FROM table_name
ORDER BY col2
Index ix2 is a perfect covering index, because it has all the columns needed to satisfy the query (the clus column(s) are always included in every index, so col1 is present also).If you wrote this query:
SELECT col2, col1, col3
FROM table_name
ORDER BY col2
Only the clustering index covers this query, so SQL would have to scan the whole table.If you modified IX2 to be:
nonclustered index on ( col2 ) include ( col3)
Then ix2 would again cover the query.Scott, I wasn't asking you, that question was for the OP. I wanted to see if he understood what a covering index was.
Is this a test? lol
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 15, 2017 at 5:51 pm
ScottPletcher - Wednesday, March 15, 2017 3:43 PMA covering index is an index that has all the columns needed to satisfy, or "cover", a given query.For example, say I have a table with 20 columns, col1 thru col20.
clustered on col1 (ix1)
nonclustered index on ( col2 ) (ix2)If I write this query:
SELECT col2, col1
FROM table_name
ORDER BY col2
Index ix2 is a perfect covering index, because it has all the columns needed to satisfy the query (the clus column(s) are always included in every index, so col1 is present also).If you wrote this query:
SELECT col2, col1, col3
FROM table_name
ORDER BY col2
Only the clustering index covers this query, so SQL would have to scan the whole table.If you modified IX2 to be:
nonclustered index on ( col2 ) include ( col3)
Then ix2 would again cover the query.
Thank you Scott for being positive.
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 15, 2017 at 9:54 pm
Lynn Pettis - Wednesday, March 15, 2017 5:28 PMScottPletcher - Wednesday, March 15, 2017 3:43 PMA covering index is an index that has all the columns needed to satisfy, or "cover", a given query.For example, say I have a table with 20 columns, col1 thru col20.
clustered on col1 (ix1)
nonclustered index on ( col2 ) (ix2)If I write this query:
SELECT col2, col1
FROM table_name
ORDER BY col2
Index ix2 is a perfect covering index, because it has all the columns needed to satisfy the query (the clus column(s) are always included in every index, so col1 is present also).If you wrote this query:
SELECT col2, col1, col3
FROM table_name
ORDER BY col2
Only the clustering index covers this query, so SQL would have to scan the whole table.If you modified IX2 to be:
nonclustered index on ( col2 ) include ( col3)
Then ix2 would again cover the query.Scott, I wasn't asking you, that question was for the OP. I wanted to see if he understood what a covering index was.
I do not intend for every thing to be a test question.
Thank you.😀
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 15, 2017 at 10:02 pm
What makes you think I am a he not a she?
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
March 16, 2017 at 8:06 am
Nothing, I use he as a generic. There is nothing offensive in that in my mind. I have lived with being called she until I take the time to correct the individual otherwise.
March 16, 2017 at 8:15 am
Welsh Corgi - Wednesday, March 15, 2017 5:47 PMLynn Pettis - Wednesday, March 15, 2017 5:28 PMScottPletcher - Wednesday, March 15, 2017 3:43 PMA covering index is an index that has all the columns needed to satisfy, or "cover", a given query.For example, say I have a table with 20 columns, col1 thru col20.
clustered on col1 (ix1)
nonclustered index on ( col2 ) (ix2)If I write this query:
SELECT col2, col1
FROM table_name
ORDER BY col2
Index ix2 is a perfect covering index, because it has all the columns needed to satisfy the query (the clus column(s) are always included in every index, so col1 is present also).If you wrote this query:
SELECT col2, col1, col3
FROM table_name
ORDER BY col2
Only the clustering index covers this query, so SQL would have to scan the whole table.If you modified IX2 to be:
nonclustered index on ( col2 ) include ( col3)
Then ix2 would again cover the query.Scott, I wasn't asking you, that question was for the OP. I wanted to see if he understood what a covering index was.
Is this a test? lol
Yes, it is. It is based on the years that Welsh Corgi has been on this site and the questions and responses given in the past. Several of us wonder if there are different people all sharing a single account over time.
Viewing 15 posts - 1 through 15 (of 28 total)
You must be logged in to reply to this topic. Login to reply