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

On which column to create index if no where clause is present ? Expand / Collapse
Author
Message
Posted Monday, November 18, 2013 12:03 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, December 18, 2014 7:11 AM
Points: 277, Visits: 699
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.



Post #1515094
Posted Monday, November 18, 2013 12:21 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: Today @ 9:22 AM
Points: 40,632, Visits: 37,094
None, there's no index useful for that query.


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 #1515098
Posted Monday, November 18, 2013 12:34 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, December 18, 2014 7:11 AM
Points: 277, Visits: 699
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.
Post #1515105
Posted Monday, November 18, 2013 12:41 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: Today @ 9:22 AM
Points: 40,632, Visits: 37,094
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 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 #1515111
Posted Monday, November 18, 2013 12:57 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 7:22 AM
Points: 13,641, Visits: 11,516
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 LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1515118
Posted Monday, November 18, 2013 1:02 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: Today @ 9:22 AM
Points: 40,632, Visits: 37,094
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 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 #1515120
Posted Monday, November 18, 2013 1:07 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 7:22 AM
Points: 13,641, Visits: 11,516
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 LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1515122
Posted Monday, November 18, 2013 3:21 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, December 18, 2014 1:37 AM
Points: 998, Visits: 3,089
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
Post #1515145
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse