SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Indexing
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

swraman
Starting Member

5 Posts

Posted - 04/23/2013 :  01:04:28  Show Profile  Reply with Quote
Does creating an index on a column remove the inherent advantage of searching a table by its primary key (an ID, for example)?

In other words, say I have a table with 2 columns,
ID (PRIMARY KEY)
email

If I do a index on email, will the command

SELECT email FROM table WHERE id = 1231

run any slower than if I don't index email? Does SQL keep a sorted copy of the table sorted by the index, or does it actually sort the original?

I am using Mysql and/or postgres if it makes a difference.

Thanks.

ahmeds08
Aged Yak Warrior

India
534 Posts

Posted - 04/23/2013 :  01:19:58  Show Profile  Send ahmeds08 a Yahoo! Message  Reply with Quote
Please post this in mysql or postgres forums..this is a sql server related forum.
not sure if the database indexing architechture for all these is same.

mohammad.javeed.ahmed@gmail.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 04/23/2013 :  12:47:00  Show Profile  Reply with Quote
In sql server it depends on what column query engine uses. The retrieval performance has no direct relationship with number of indexes present. However any DML operation on the table might get slower on addition of new indexes.
The query analyser will just see whats the easiest way of finding record based on search fields used. Based on it, it may choose to traverse the actual table (or clustered index if present) or traverse the nonclustered index table.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000