Is it possible to create an index from columns of 2 different tables?
If not, how do we optimize a query that does a group by on columns of 2 different tables?

For example: the following statement

explain select p.name from Person p join JobStatus js  
group by p.name,js.job_tickets  
order by p.name,p.lastname, pm.job_tickets;  

Uses indexes if I have for (p.name,p.lastname) and for job_tickets.
But I have noticed that on other queries and with more than one joining table the index is omitted.

  • This is hard to answer because your query isn't complete... there's no ON for the join, and one stray reference to a column from a table with the alias "pm." – Michael - sqlbot Sep 8 '13 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.