Can anyone provide any concrete evidence of performance when comparing
int = int
and:
string = string
in
OK interesting question always took it as read that integer was quicker and never actually tested it. I took 1M Random Surnames and types from a list of Contacts from my data into a scratch database with no indices or primary key just raw data. No measurement was made over the range of my data in either of the columns has not been standardised so reflects the reality of my database rather than a pure statistical set.
select top 100 * from tblScratch where contactsurname = '' order by NEWID()
select top 100 * from tblScratch where contacttyperef = 1-22 order by NEWID()
The Newid is there to randomise the data list out each time. Quickly ran this for 20 surnames and 20 types. Queries were run surname than ref then surname. Searching for the reference number was almost 4x quicker and used about 1/2 so the books were right all those years ago.
String -
SELECT TOP 100 * FROM tblScratch WHERE contactsurname = 'hoare' ORDER BY NEWID()
Duration 430ms
Reads 902
CPU 203
Integer -
SELECT TOP 100 * FROM tblScratch WHERE contacttyperef = 3 ORDER BY NEWID()
Duration 136ms
Reads 902
CPU 79