Skip to content

use with_recursive for faster access on rails >= 7.2#97

Open
patriciomacadden wants to merge 1 commit intoamerine:masterfrom
patriciomacadden:with_recursive
Open

use with_recursive for faster access on rails >= 7.2#97
patriciomacadden wants to merge 1 commit intoamerine:masterfrom
patriciomacadden:with_recursive

Conversation

@patriciomacadden
Copy link
Copy Markdown

@patriciomacadden patriciomacadden commented Nov 21, 2024

Rails >= 7.2 added #with_recursive, which allows us to write CTE (Common Table Expressions) in postgresql, sqlite and mysql.

The bigger the tree gets, the slower is traversing it with the current implementation. This PR allows to fetch the whole tree in just 1 query by using #with_recursive.

Also, added newer versions of ruby and rails to the ci matrix

@felixbuenemann
Copy link
Copy Markdown
Collaborator

  • What happens if the underlying database does not support recursive queries (eg. MySQL < 8)?
  • The code uses raw sql without proper quoting
  • Is it really necessary to duplicate so many methods with recursive and non-recusrive version ir can they share more code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants