I asked this question in which I explained that I’m trying to get weekly point allocations from members of staff – including those that have allocated zero.
I have two tables:
Staff (140 rows) ID, Firstname, Surname, Position, Faculty, Subject, Hours, Allocation
Transactions (140,000 rows) Transaction_ID, Datetime, Giver_ID, Recipient_ID, Points, Category_ID, Reason
The SQL statement I’ve been trying is this:
SELECT
CONCAT(s.Firstname, " ", s.Surname) AS `Staff Name`,
COALESCE(SUM(t.Points), 0) AS `Points Allocated`
FROM staff s
LEFT JOIN transactions t ON t.Giver_ID = s.ID and t.Datetime >='2012-10-08'
GROUP BY s.ID
ORDER BY `Points Allocated` ASC
The query works as intended but it’s taking ~6 seconds to run.
The only index I have on either table is their Primary Keys.
The result of a EXPLAIN on this query states:

Sadly, I have no idea what that means! How can I go about optimising my query or tables to improve the run-time of this query?
Thanks in advance,
Have you tried simply adding an index key on the transaction.Giver_Id and also transaction.dateTime