Hi, I've got an issue with a slow query. I'm using the MAX function in an initial query (detailed below) to obtain the highest VisitorSignInID - typically this completes within a second. Upon running the second query below to pull in additional field values from the underlying table with approximately 20k records, it takes approximately 20 seconds. Is there a way of speeding up this process?
SELECT VisitorSignInDetailsTBL.NameofVisitor, Max(VisitorSignInDetailsTBL.VisitorSignInID) AS MaxOfVisitorSignInID
FROM VisitorSignInDetailsTBL
GROUP BY VisitorSignInDetailsTBL.NameofVisitor
ORDER BY VisitorSignInDetailsTBL.NameofVisitor;
SELECT VisitorSignInDetailsTBL.NameofVisitor, VisitorSignInDetailsTBL.VehReg, Visitor_Search_Existing_Query_1.MaxOfVisitorSignInID
FROM VisitorSignInDetailsTBL INNER JOIN Visitor_Search_Existing_Query_1 ON VisitorSignInDetailsTBL.VisitorSignInID = Visitor_Search_Existing_Query_1.MaxOfVisitorSignInID
ORDER BY VisitorSignInDetailsTBL.NameofVisitor;