busboy — 2011-02-04T20:22:17-05:00 — #1
It looks innocent enough, but apparently I'm structuring something incorrectly.
SELECT u.firstname, u.lastname, n.nID, n.date, n.priority, n.type, n.sender, n.recipient, n.subject, n.message FROM users u, notifications n WHERE n.sender = u.email order by priority limit 5
scallioxtx — 2011-02-04T20:28:04-05:00 — #2
There's not much to go on here, but you should at least drop that carthesian product in favor of a JOIN:
FROM users u
JOIN notifications n
ON n.sender = u.email
Please post the SHOW CREATE TABLE for both the users and notificiation tables as well as the result of the EXPLAIN of the query above.
r937 — 2011-02-04T22:06:32-05:00 — #3
you're asking the database engine to retrieve all notifications forall users, and then sort all the rows thus obtained by priority
is there an index on the priority column? on the sender column?