I have a query which takes ages to run mainly due to a join between 2 tables on a PK and FK.
The Key is prefixed with 2 letters (which is always the same, RN) followed by 7 digits So RN1234567 for example.
However if I strip out the first 2 letters (
right(tbl1.id,7) = right(tbl2.id,7) )and join only on the digits the query speed improves greatly. Why is this?