brendon / acts_as_list

An ActiveRecord plugin for managing lists.
http://brendon.github.io/acts_as_list/
MIT License
2.04k stars 355 forks source link

refactor: memoize record loads in `move_(higher|lower)` #415

Closed jamesdabbs closed 3 months ago

jamesdabbs commented 1 year ago

Heyo 👋🏻 I work at Procore, and we're looking at the performance (in particular - the database query pressure) of acts_as_list. I think this PR should be a quick win, but I'm hoping we can contribute a number of performance improvements over time. Happy to chat and swap notes if that'd ever be helpful.

lower_item makes a DB call; memoizing it in move_lower allows us to save a few queries. (Sim. higher_item and move_higher).

brendon commented 3 months ago

Hi @jamesdabbs, just closing this for now as you never got back to my comments. If you want to pursue it, let me know :)

Also check out https://github.com/brendon/positioning as an alternative gem I just finished writing that works in similar ways but it much simpler in code.