I have the following 3 tables:
publications (primary key = article)
article | title | pubType
authors (primary key = *author_name*)
author_name | author_somethingelse
pub_author_map
article | author_name
Given a value for pubType, I need to select information about the articles, including authors. To do this, I have
SELECT p.article, p.title, p.dateTime, pam.author_name FROM publications p
LEFT JOIN pub_author_map pam ON pam.article = p.article
LEFT JOIN authors a ON a.author_name = pam.author_name
WHERE p.pubType = '$pubType' ORDER BY p.article LIMIT 10
Even with a LIMIT 10, this query clocked in at about 29s. There are 1500 rows in publications and 3000 rows in pub_author_map.
How can I optimize the above query?
Add indicies
pub_author_map on column article
publications on column pubType
for example like this.