Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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.

share|improve this question
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.