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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Which is quicker: searching by int or varchar?

Author  Topic 

monaya
Yak Posting Veteran

58 Posts

Posted - 2009-09-27 : 23:39:33
Is there any serious difference in speed in terms of querying a table by a unique primary key integer column or varchar column that has no duplicate textual entries.

smarty
Starting Member

13 Posts

Posted - 2009-09-28 : 03:07:08
Depends on how many records you have in the table.
But in short, yes there is a serious difference in speed (use INT always)

-----------------------------------
Free SQL server monitoring for DBA's
www.realsmartsoftware.co.uk
Go to Top of Page

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2009-09-28 : 03:25:01
Int is a very index friendly, however there are many scenerio's when it is not the right choice when using a primary key. The statement of "use int always", is not necessarly rrue.


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-09-28 : 03:30:55
A fixed size datatype is generally faster to search than a variable size datatype.
A smaller size datatype is generally faster to searach than a larger size datatype.


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -