-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
virtual depth_cache #662
Comments
Looks like rails 7 supports generated columns for both mysql and postgres. In the current master (will be the 5.0 branch), I have implemented Currently it supports updating all depth_cache values in a single query. Let me know if this helps with your problem or if you have suggestions to make it better |
Had a few ideas around this and put together a PR to share. |
Also, there is the ability to update all depth values using a single query. Not sure if this would work for you. |
I noticed a problem updating the depth_cache in the big tree.
Since it is a sequential update, the updates are issued in a large number of UPDATE statements.
I have solved this problem with generated columns. (It depends on MySQL, but Postgres may be able to handle it as well as Rails7)
rails/rails#41856
This example depends on
ancestry_format: :materialized_path2
.This solution has the problem that existing scopes cannot be used.
ancestry/lib/ancestry/has_ancestry.rb
Lines 98 to 102 in 8f06902
The text was updated successfully, but these errors were encountered: