Index on a varchar field.Will it work faster as int field ?
If we create index for a varchar column then will it work as fast as integer column does. Please also mention the index structure of the varchar value indexing.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 1, 2013, 8:00 PM EDT
it depend on size of your varchar type field.
if your varchar size more than 10 then big int would be the best (as per my knowledge).
BigInt is 8 bytes; the VARCHAR's can be smaller if the size of the data is small, so it really depends on your data.
please refer
http://ask.sqlservercentral.com/questions/1796/indexing-varchar-vs-bigint.html
hope this will help you to understand.
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 1, 2013, 1:54 AM EDT
Hi,
Performance of Index on int column is faster than index on varchar column.Int uses 4 byte whereas varchar is use n byte depending on size of data inserted.
please refer below link, it might help you to understand this
http://lostechies.com/jimmybogard/2012/07/18/troubleshooting-sql-index-performance-on-varchar-columns/
http://sqlinsights.blogspot.in/2009/03/compare-varchar-and-int-implicit-vs.html
Santosh YadavRank #6,715 · 258 reputationPosted Apr 1, 2013, 7:14 PM EDT
Thanks for your reply.
Santosh YadavRank #6,715 · 258 reputationPosted Apr 2, 2013, 1:56 AM EDT
I think you are absolutely right. Actually I have bit of confusion over there and don't know the correct answer.