Ranged selects always miss the last range #12624
Merged
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.
I found this bug because some of my categories were empty. catalog_category_product_index did not contain all category product relations that are in catalog_category_product. Per category type (anchor, non-anchor) the highest category id's were missing from the index.
Description
Ranged selects always miss the last range:
Suppose you have a total item count of 530 items:
Batch size: 500
Offset: 0
(batch size + offset) = 500
500 <= 530 is TRUE, so generate a query with offset 0 and limit 500
Returns item 1 - 500
Batch size: 500
Offset: 500
(batch size + offset) = 1000
1000 <= 530 is FALSE, so DO NOT generate a query with offset 500 and limit 500
Query is not created
Does not return items 501 - 530
The actual check should be:
Suppose you have a total item count of 530 items:
Batch size: 500
Offset: 0
0 <= 530 is TRUE, so generate a query with offset 0 and limit 500
Returns item 1 - 500
Batch size: 500
Offset: 500
500 <= 530 is TRUE, so generate a query with offset 500 and limit 500
Returns item 500 - 530
Batch size: 500
Offset: 1000
1000 <= 530 is FALSE, so DO NOT generate a query with offset 1000 and limit 500
Query is not created
Fixed Issues (if relevant)
Manual testing scenarios
Contribution checklist