Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


On which column to create index if no where clause is present ?


On which column to create index if no where clause is present ?

Author
Message
Shadab Shah
Shadab Shah
Old Hand
Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)

Group: General Forum Members
Points: 307 Visits: 798
Hi Experts,

On which column should one create index if no WHERE clause is specified.
example

 Select * from table_name  



No identity column is present on the table(because none is needed :-) ). I search this on major forum but i guess i may have got my keywords incorrect.
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47165 Visits: 44346
None, there's no index useful for that query.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


Shadab Shah
Shadab Shah
Old Hand
Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)Old Hand (307 reputation)

Group: General Forum Members
Points: 307 Visits: 798
GilaMonster (11/18/2013)
None, there's no index useful for that query.


I may be wrong over here but if none index is created on the table it gets stored on heap and retrival is slow. Hence i think one index should be created it can be on a random column.
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47165 Visits: 44346
I disagree with you completely.

Every table should have a clustered index, but certainly not on 'a random column'. The column has to be carefully chosen. That's irrelevant to this question though, there is no index useful for the query you posted, therefore it's useless to create any index for this particular query.

Oh, and heap means no clustered index, not no indexes at all.


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


Koen Verbeeck
Koen Verbeeck
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16374 Visits: 13199
Shadab Shah (11/18/2013)
GilaMonster (11/18/2013)
None, there's no index useful for that query.


I may be wrong over here but if none index is created on the table it gets stored on heap and retrival is slow. Hence i think one index should be created it can be on a random column.


With or without index, you're doing a full table scan, so indexes are worthless.
Maybe - and just maybe - you might benefit from a (clustered) columnstore index - if you're using SQL Server 2012 or 2014 - because those indexes compress the data really efficient and you might get less IO.
But this depends on a lot of factors, such as for example the number of unique values in your columns. It might even not help at all.
If you were not using * - shame on you - but just selecting a few columns, the columnstore index would give you some real benefit, as the reduced number of columns has a great impact on IO.



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at SQLKover.

MCSA SQL Server 2012 - MCSE Business Intelligence
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47165 Visits: 44346
Koen Verbeeck (11/18/2013)
Maybe - and just maybe - you might benefit from a (clustered) columnstore index - if you're using SQL Server 2012 or 2014 - because those indexes compress the data really efficient and you might get less IO.


and whether the table is read only or not (SQL 2012).


Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
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


Koen Verbeeck
Koen Verbeeck
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16374 Visits: 13199
GilaMonster (11/18/2013)
Koen Verbeeck (11/18/2013)
Maybe - and just maybe - you might benefit from a (clustered) columnstore index - if you're using SQL Server 2012 or 2014 - because those indexes compress the data really efficient and you might get less IO.


and whether the table is read only or not (SQL 2012).


Indeed. A pretty important limitation in SQL 2012.



How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at SQLKover.

MCSA SQL Server 2012 - MCSE Business Intelligence
Sean Pearce
Sean Pearce
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1170 Visits: 3432
Shadab Shah (11/18/2013)
Hi Experts,

On which column should one create index if no WHERE clause is specified.
example

 Select * from table_name  



No identity column is present on the table(because none is needed :-) ). I search this on major forum but i guess i may have got my keywords incorrect.




Your example query is asking for ALL the columns and ALL the rows in your table. The only possible way to satisfy this query is to read ALL the pages. An index would not help you here.



The SQL Guy @ blogspot

@SeanPearceSQL

About Me
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search