Conversation
- Refactored meta relationship logic to use SQL Window Functions and custom Eloquent builder/relation classes for latest/historic meta queries. - Introduced `MetaBuilder` and `LatestMetaRelation` for advanced meta querying with window functions. - Changed `allMeta`, `meta`, `publishedMeta`, `plannedMeta`, and `historicMeta` relationships to use the new relation logic. BREAKING CHANGE: Removed `withoutCurrent`, `withoutHistory` and `joinLatest` scopes in favor of `current` (or `onlyCurrent`) and `history` (or `onlyHistory`) scopes. BREAKING CHANGE: The `onlyCurrent` scope can no longer be used on any of the `meta` relations, but you can still use it on the `Meta` model directly, like `Meta::onlyCurrent()`.
BREAKING CHANGE: Laravel 11+ is required now
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 PR introduces a new major version (v3), which comes relatively soon after the v2 release. I’m aware that this timing isn’t ideal. The main reason for moving to v3 so quickly is that a few performance decisions in v2 turned out not to be going far enough.
The performance improvement is remarkable though: Querying the currently valid meta values for a model takes a full 350 ms in the test environment with approximately 80k data records using version 2.x, while with version 3.x it only takes 3 ms, which is more than 100 times faster.
The following changes are included in this PR:
MetaBuilderandLatestMetaRelationfor advanced meta querying with window functions.allMeta,meta,publishedMeta,plannedMeta, andhistoricMetarelationships to use the new relation logic.withoutCurrent,withoutHistoryandjoinLatestscopes in favor ofcurrent(oronlyCurrent) andhistory(oronlyHistory) scopesonlyCurrentscope can no longer be used on any of themetarelations, but you can still use it on theMetamodel directly, likeMeta::onlyCurrent()