I have a query which was written like this
select p.id, p.name, p.money, s.name, agents.name
from projects p, status s, agents
where p.stage = 0
and p.status = s.id
and p.agent = agents.id
order by p.name

Despite the fact that p.name is indexed, 'explain' shows in the extra column
'using temporary; using filesort'. I don't understand why.

Also, I have reason to believe that this query is bumping up the
'select_full_join' count, so I rewrote it as
select p.id, p.name, p.money, s.name, agents.name
from projects p
left join status s on s.id = p.status
left join agents on agents.id = p.agent
order by p.name

This doesn't improve the data returned by 'explain', and it seems that
'select_full_join' increased by two (instead of one, as before).

The 'status' and 'agents' tables exist in the query only to give values to
the pointers stored in the 'projects' table (after all, this is a relational
database with each name being stored only once).

So what's the most efficient way to get at the data?

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to