I have a MySQL database with over 10k rows. When I execute the query to get all rows within 24 hours, it takes very long to get the results:
$sql = 'SELECT *, DATE_FORMAT(m.time, "%d.%m.%Y %H:%i:%s") AS date
FROM markers m,pid p
WHERE m.time >=DATE_SUB(NOW(), INTERVAL 24 HOUR)
AND m.pidID=p.id';
I have read about indexing of tables, but could not adapt it to my query. Can anyone please explain how to change the above query with indexing so the query does not a full table scan?