View Single Post
Old 01-20-2013, 05:37 AM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.

Last edited by Old Pedant; 01-20-2013 at 05:41 AM..
Old Pedant is offline   Reply With Quote