I asked Google but I am still confused.
1) Is there a problem in indexing a Varchar column. When I shouldn't, and When I should
2) Index a char column VS Varchar column.
Thanks
1 - Index it if you are querying it and it is selective enough. If it is a column where 90% of the values are the same, there won't be much point.
2 - This is not a question, but I will guess you want to know if you should. Yes, if you query it and it meets the criteria above.
varchar
is about 50 chars max.char
vs. varchar
are fixed size vs. variable size (ie. char(100)
) always takes 100 bytes in data page, varchar(100)
takes up to 100)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With