Repository navigation
Added efficient version query utilities and composite indexes - #376
Merged
Merged
Conversation
This commit adds several features to optimize version queries: 1. version_at() class method on version objects - efficiently retrieve the version that was active at a specific transaction using an optimized query pattern for both validity and subquery strategies 2. all_versions() class method with link option - batch fetch all versions for an entity in a single query, optionally pre-populating the previous/next navigation caches to avoid N+1 queries 3. Automatic composite indexes on version tables - creates (pk_columns, transaction_id DESC) index for efficient version lookups and (pk_columns, transaction_id, end_transaction_id) for validity strategy temporal queries. Controlled by create_composite_index option. 4. Updated documentation with index recommendations and efficient query patterns
The _build_composite_indexes method was incorrectly using parent table
primary key column names to access version table columns. When column
aliases are used (e.g., id = Column('_id', ...)), the column name differs
from the column key used for table access.
Fixed by getting primary key columns directly from the version table
itself rather than mapping parent table column names, which properly
handles column alias cases.
josecsotomorales
force-pushed
the
feat/version-query-optimizations
branch
from
January 22, 2026 21:18
529446b to
8989b36
Compare
marksteward
approved these changes
Jan 23, 2026
Collaborator
|
Nice, looks like it'll fix #349. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds several features to optimize version queries:
version_at() class method on version objects - efficiently retrieve the version that was active at a specific transaction using an optimized query pattern for both validity and subquery strategies
all_versions() class method with link option - batch fetch all versions for an entity in a single query, optionally pre-populating the previous/next navigation caches to avoid N+1 queries
Automatic composite indexes on version tables - creates (pk_columns, transaction_id DESC) index for efficient version lookups and (pk_columns, transaction_id, end_transaction_id) for validity strategy temporal queries. Controlled by create_composite_index option.
Updated documentation with index recommendations and efficient query patterns