Closed matthew-andrews closed 11 years ago
+1 from me
getting an email about a new issue and seeing that it includes a patch with a 5x performance improvement is awesome :) thanks!
It looks good to me. I've never touched this part of the code before though, so I'll leave it to @ixti or @PowerKiKi to decide when to merge.
:shipit: from me. I don't see any potential problems here...
@ixti Hold on, it does not pass the tests at the moment... (Have you considered using travis-ci to build on PR?)
@hdgarrood Well it varies... Sometimes it's only about a 3x performance improvement :).
@matthew-andrews I was considering to use travis-ci, but it required some work to do, and then i had not time, so I stepped out of maintenance (thanks @PowerKiKi and @hdgarrood for their work on maintaining this project). Nowdays I think about complete rewriting of a plugin nearly from scratch :D
Ok the tests pass now. (Sorry, I should have checked that first).
@ixti - Ah yes that makes sense - this plugin depends on redmine being there, doesn't it...
@matthew-andrews Yeah, but that part is solvable in fact :D Just didn't had much time to achieve that goal.
@PowerKiKi did you have a chance to have a look through this pull request?
Many thanks, Matt.
Sorry for the delay. And thanks a lot for the PR
No problem, thanks for merging!
We have a fairly good size redmine install with ~13,000 issues and we have grown to rely on this plugin - about ~500 tags. Unfortunately this plugin has become quite a significant bottleneck.
The issue seems to lie within this line:
The underlying SQL Rails generates is:-
Which, considering it only needs the
id
, is far more information that it really needs.My initial thought was to swap out the line above with
pluck
:-But I immediately ran into a Rails bug (https://github.com/rails/rails/issues/6132?source=cc, https://github.com/rails/rails/issues/8743?source=cc) within
to_sql
, whichpluck
makes use of.Also
pluck
only fixes part of the performance issue - even using itids_scope.pluck(:id).push(-1)
on our redmine install would generate an array of 7505 ids.I then thought instead of downloading all the ids into rails so that they can be converted into an SQL query to send back again to MySQL it would be better to pass the query that
ids_scope
would have generated in as a subquery, which is what I've done (plus a little hack to add in the bits of SQL rails forgets to add).Before:
After:
Thank you for an otherwise marvellous plugin,
Matt
(PS. The commit "Way, way cleaner implementation" is in reference to my first attempt at addressing this, which was horrible :-) https://github.com/matthew-andrews/redmine_tags/commit/f6e49c795cd386a7bbcfa2ac2f8d5ba7e63f42aa)