You're looking for minimum value of id
for minimum value of matchStrength
. Therefore, you can do:
SELECT
id
FROM
matchTrip
WHERE
userTripId = :tripId
ORDER BY
matchStrength,
id
LIMIT 1
in any case you need to have index via matchStrength
(I think you already have it for id
field). As for performance - you have to do measures, there's no certain other way to be sure that one thing is better than another in terms of performance.