php-b-grader
php-b-grader

Reputation: 3315

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

Upvotes: 0

Views: 47

Answers (1)

D P
D P

Reputation: 328

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);

Upvotes: 2

Related Questions