I’m trying to see if a particular hashcode is within the newest 1000 inserts for a table, what is the most efficient technique to achieve this query:
SELECT a.idsearch
FROM searches a
WHERE a.hashcode = 549716444
AND a.idsearch > (SELECT MAX(b.idsearch) - 1000
FROM searches b);
idsearch is an auto_increment column and is the PK.
Use your existing query but add two indexes if they don’t already exist: