I have a database containing addresses, one address per Row. Contains every address in the UK, so ~28 million rows. One of the columns is 'Street', which I am using to perform searches. I have a non-unique, non-clustered index on this column.
I'm having inconsistencies with search speeds however.
select * from Postcodes where Street = 'London Road'
Takes ~1s to run.
select * from Postcodes where Street like'London Road%'
Likewise takes about a second.
declare @Street varchar(20) = 'London Road%'
select * from Postcodes where Street like @Street
However, this statement, although apparantly identical to the second, takes about 40 seconds to run.
I'm at a complete loss to what is causing this speed difference. Any ideas?