-
Notifications
You must be signed in to change notification settings - Fork 127
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
Make VersionClass.versions a plain list #332
Comments
I'm not very fluent in SqlAlchemy. Would this require reading all versions when a model is read? Also, the PR I put up removed negative indexing in the tests in favor of |
The previous code would read all versions anyway, but without that being obvious. I'm wondering whether we go the whole way and just always return all versions. |
For my use (iterating through all versions of a small database with about 2-3 versions per object) returning all versions will be significantly faster, but for other access patterns (such as getting only previous version of object with large number of versions) it could be significantly slower. @marksteward 's suggestion of adding helper to get particular versions by index or version count seems like a good way to support both access patterns. I'm not that familiar with sqlalchemy internals but tried changing
dynamic to selectin (found at https://docs.sqlalchemy.org/en/14/orm/loading_relationships.html#selectin-eager-loading ) but it didn't seem to help the performance of my code.
|
Read all transactions into memory to display version history. This is a bit ugly, not tested very well but speeds up generating the render cache from about a minute to a few seconds. It is a work-around for kvesteri/sqlalchemy-continuum#332 .
This (VersionClass.versions) uses a
lazy='dynamic'
relationship, which is on its way out:This also supports negative indexes, which a lot of the tests use. They were never performant and are removed in SQLAlchemy 2.0. While we could create an accessor that uses
order_by
to do the right thing, it's probably less surprising to just make.versions
return a list instead of usinglazy='dynamic'
.We could expose a separate helper to get particular versions by index or version count. Do people think this is useful?
The text was updated successfully, but these errors were encountered: