Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
  #1  
Old April 28th, 2003, 09:31 AM
X-2-X X-2-X is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Lagos,NIGERIA.
Posts: 21 X-2-X User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ms sql server indexes .....

i have succesfully created indexes with Tsql . I created a unique non clustered index on a column on which i expect unique entry's and plan to issue select statements to retrive only one entry at a time . I had expected to see the entrys in this coumn arranged in ascendinding or descending order according to the index but this doesnt happen. Enterprise manager shows that an index exits but i am not sure if the index is having any effect on query speed.

Is there nothing to worry about or any way to verify the effect of the index ?

Reply With Quote
  #2  
Old April 28th, 2003, 10:12 AM
MattR MattR is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: High above the mucky-muck (Columbus, OH)
Posts: 266 MattR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to MattR
Quote:
I had expected to see the entrys in this coumn arranged in ascendinding or descending order according to the index but this doesnt happen


See? Are you looking at the B tree? Row are only sorted on disk according to the clustered index.

By default the values in the nonclustered indexes are sorted ASC but that means you will still need to put an ORDER BY indexed_col ASC in order to extract your rows in a meaningful fashion (and use the index to avoid a disk/memory sort).

Issuing a SELECT * FROM table may come back in sorted order by the clustered index but there are no guarantees -- make sure you use an ORDER BY.

Reply With Quote
  #3  
Old April 29th, 2003, 05:27 AM
X-2-X X-2-X is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Lagos,NIGERIA.
Posts: 21 X-2-X User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up

Well first thank you.

I dont seem to understand your "order by" idea ( as in the manner of implenting it ). I dont know whether this is implemented in the Tsql statement to create the indexes or tru enterprise manager , or .....

Also , i would really like to know if in your opinion , creating such an index will have any effect on the the particular type of query i said i will be issuing especially as the Index Tuning Wizard reported that it could not recommend any index for my tables

Thanks again

Reply With Quote
  #4  
Old April 29th, 2003, 05:35 AM
MattR MattR is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: High above the mucky-muck (Columbus, OH)
Posts: 266 MattR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to MattR
What is your SQL and your CREATE TABLE and CREATE INDEX statements?

Reply With Quote
  #5  
Old April 30th, 2003, 11:56 AM
X-2-X X-2-X is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: Lagos,NIGERIA.
Posts: 21 X-2-X User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
well the TSQL format is :


CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
ON { table | view } ( column [ ASC | DESC ] [ ,...n ] )
[ WITH < index_option > [ ,...n] ]
[ ON filegroup ]

< index_option > :: =
{ PAD_INDEX |
FILLFACTOR = fillfactor |
IGNORE_DUP_KEY |
DROP_EXISTING |
STATISTICS_NORECOMPUTE |
SORT_IN_TEMPDB
}


to actually create my indexes i used :

CREATE UNIQUE NONCLUSTERED INDEX employeeID_ind
ON emp_pay (employeeID)

this as u might have seen ignores everything after the "WITH" clause. I then used enterprise manager to specify an ascending order option .


I hope you understand the junk i posted.

Reply With Quote
  #6  
Old April 30th, 2003, 01:21 PM
MattR MattR is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: High above the mucky-muck (Columbus, OH)
Posts: 266 MattR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to MattR
There are three situations in which this index will (probably) be used:
1: When running queries like
SELECT ... FROM emp_pay WHERE employee_id = 123
2: When running queries like:
SELECT employee_id FROM emp_pay
3: When running queries like
SELECT .. FROM emp_pay ORDER BY employee_id ASC (it may read it backwards if you specify DESC).

Reply With Quote
  #7  
Old April 30th, 2003, 01:25 PM
MattR MattR is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: High above the mucky-muck (Columbus, OH)
Posts: 266 MattR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to MattR
Enterprise manager shows you what is in the database, not how it is stored.

A non-clustered index is a separate data structure than the rows in your table. It creates a listing of all the values in the columns you specified and orders these.

So, your emp_pay table will look something like:
123, '$123,000',
333, '$20,000',
200, '$33,000'

But the index will look like:
123,
200,
333

A clustered index is the SAME as your table (more or less). It will physically move rows around in order to match the ordering in your clustered index. This is what you will see in Enterprise manager.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > ms sql server indexes .....


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway