backlogs/redmine_backlogs — pull request #526 by rbaranga (2012-05-08 11:32:46+00:00)
Title: DB Query optimisation 

Hi,

with our project it takes over 1 minute to load issues that have story points enabled. I've traced to be the SQL:

SELECT * FROM `issues` WHERE (tracker_id in (6,2,3,4,5) and exists(select 1 from rb_journals where rb_journals.issue_id = issues.id and property = 'fixed_version_id' and value = '302'))

With this change, the SQL becomes:

SELECT `issues`.* FROM `issues` JOIN `rb_journals` ON `rb_journals`.issue_id = `issues`.id and property = 'fixed_version_id' and value = 302 WHERE (tracker_id in (6,2,3,4,5)

The new SQL runs a lot faster then the old one (before: 214.628 sec, after: 0.017 sec), with a DB of about 7000 issues.

Cheers,
Radu