[5.6] Add builder/grammar support for row values in where condition #22446
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.
Support for "row values" is mostly useful when implementing pagination with keysets aka seek method.
Well known pagination with offset/limit has almost linearly bad performance characteristics with every "page" turned. They can't make use of an index to efficiently jump to the result page and thus have to always read from the beginning.
An alternative way is to define predicates to jump to the desired page which can make use of indices. Characteristics of such paginations are:
This PR implements the low-level building block. Example:
->where(…)->orderBy(…)->offset(100)->limit(10)
->where(…)->whereRowValues(['last_update', 'ticket_numbner'], '<', ['2017-12-15 23:00:00', 123])->orderBy(…)->limit(10)
(iff the business logic of your application allows it)
The benefits/performance characteristics as well as in-depth examples how and why this works are well described at:
Note
->whereRaw()
but after reading http://use-the-index-luke.com/no-offset I figured a direct support for this could be welcomeRowValues
may not be obvious to related to this "keyset pagination" or "seek method". But OTOH this seems to be the term describing this particular syntax (I'm not an expert on this topic), that's why I choose it instead of->whereSeek
or->whereKeysetPagination
…This may be left open for the future to directly support this via something like
->paginateKeyset()
(just thinking out loud)