Note that there are some explanatory texts on larger screens.

plurals
  1. POhow can I optimize a query with multiple joins (already have indexes)?
    primarykey
    data
    text
    <pre><code>SELECT citing.article_id as citing, lac_a.year, r.id_when_cited, cited_issue.country, citing.num_citations FROM isi_lac_authored_articles as lac_a JOIN isi_articles citing ON (lac_a.article_id = citing.article_id) JOIN isi_citation_references r ON (citing.article_id = r.article_id) JOIN isi_articles cited ON (cited.id_when_cited = r.id_when_cited) JOIN isi_issues cited_issue ON (cited.issue_id = cited_issue.issue_id); </code></pre> <p>I have indexes on all the fields being JOINED on. </p> <p>Is there anything I can do? My tables are large (some 1 Million records, the references tables has 500 million records, the articles table has 25 Million). </p> <p>This is what EXPLAIN has to say: </p> <pre><code>+----+-------------+-------------+--------+--------------------------------------------------------------------------+---------------------------------------+---------+-------------------------------+---------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------------+--------+--------------------------------------------------------------------------+---------------------------------------+---------+-------------------------------+---------+-------------+ | 1 | SIMPLE | cited_issue | ALL | NULL | NULL | NULL | NULL | 1156856 | | | 1 | SIMPLE | cited | ref | isi_articles_id_when_cited,isi_articles_issue_id | isi_articles_issue_id | 49 | func | 19 | Using where | | 1 | SIMPLE | r | ref | isi_citation_references_article_id,isi_citation_references_id_when_cited | isi_citation_references_id_when_cited | 17 | mimir_dev.cited.id_when_cited | 4 | Using where | | 1 | SIMPLE | lac_a | eq_ref | PRIMARY | PRIMARY | 16 | mimir_dev.r.article_id | 1 | | | 1 | SIMPLE | citing | eq_ref | PRIMARY | PRIMARY | 16 | mimir_dev.r.article_id | 1 | | +----+-------------+-------------+--------+--------------------------------------------------------------------------+---------------------------------------+---------+-------------------------------+---------+-------------+ 5 rows in set (0.07 sec) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload