Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Indexing

Author  Topic 

swraman
Starting Member

5 Posts

Posted - 2013-04-23 : 01:04:28
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

737 Posts

Posted - 2013-04-23 : 01:19:58
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

52326 Posts

Posted - 2013-04-23 : 12:47:00
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
   

- Advertisement -