LifeinAsia - 9:01 pm on Jun 25, 2012 (gmt 0)
I have a new table that will have a key of the form 12345-adbde, where the 12345 part will always be INT and the abcde part will be a VARCHAR.
Option 1 is to have MyKey field be a VARCHAR(30), with an index on MyKey. Option 2 is to have MyKey1 field be INT and MyKey2 field be a VARCHAR(20), with an index on both MyKey1 and MyKey2.
So searching with option 1 would be:
Searching with option 2 would be:
WHERE MyKey1=12345' AND MyKey2='abcde'
I'd say 99% of the queries would be like this, although maybe 1% would just want the numeric part (easy enough to write for option 2, slightly more complicated for option 1, but still doable).
Would there be any performance advantage by using option 2? Note: there would only be about 2 dozen different values for the numeric part. For the 1% queries, I think there would be a definite performance boost with option 2.