Code:
SELECT DISTINCT pac2_titles.title AS page_title, pac2_notifications.*
FROM pac2_notifications LEFT JOIN pac2_titles
ON pac2_titles.uri = pac2_notifications.what
WHERE what = '/demo.php' AND email != 'hehe@aol.com'
Okay, I have to ask.
What does EXPLAIN say if you forget the JOIN and just do
Code:
SELECT *
FROM pac2_notifications
WHERE what = '/demo.php' AND email != 'hehe@aol.com'
I think MySQL has rejected using a key for the pac2_notifications table because it has determined it can get the needed records (it is saying there are only 2 matches?!?) fast enough without using a key.
And I would *guess* that the reason for the USING TEMPORARY stems from your
DISTINCT usage.
And are you sure you need the DISTINCT?
Because you are using
pac2_notifications.* your DISTINCT will only do something to that table if you have two *IDENTICAL* records in the table.
I would hope that is extremely unlikely (I'd hope you have a PRIMARY KEY on that table, in fact, making duplicates in that table impossible).
So the only reason for the DISTINCT would be if you expected to find multiple matches in the other table,
pac2_titles, all with the same
title value.
If that's the only reason for your DISTINCT then possibly we can rearrange the query to move it to a subquery. Whether that would help performance or not, I don't know. But it would be worth a shot.