Search code examples
mysqlindexingentity-attribute-value

Improve JOINED SQL Query efficiency


I have a SQL query which is taking a long time to load. I think I need to add some indexes but I'm not sure what indexes I should add.

This is the main SQL that is executed: SQL FIddle: http://sqlfiddle.com/#!9/f440e2/1

This can take up to and beyond 10 seconds when there is > 20000 records

What indexing would you suggest to improve efficiency?

EXPLAIN Results:

enter image description here

EXPLAIN Results After Modifications:

enter image description here


Solution

  • You can add 2 more index in your tables.

    ALTER TABLE `OpenROData` ADD INDEX key_value_idx (key_value);
    ALTER TABLE `OpenRONotes` ADD INDEX ro_number_idx (ro_number);