Skip to content

[Forwardport] Ensure integer values are not quoted as strings #18961

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

Closed

Conversation

gelanivishal
Copy link
Contributor

@gelanivishal gelanivishal commented Oct 31, 2018

Original Pull Request

#18287

Description

In cases where indexers does a filtering in the style of WHERE entity_id IN (...) there is a performance penalty if IDs are passed as strings, rather than integer values. This is especially visible on larger data sets. This pull request should cover some common occurrences of this.

Fixed Issues (if relevant)

  1. n/a

Manual testing scenarios

  1. n/a

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @gelanivishal. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me $VERSION instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

Copy link
Contributor

@DanielRuf DanielRuf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lines are now longer than 80 chars and readability is partly worse now.

Also int typecasting is faster than intval.

@@ -284,8 +284,8 @@ public function update()

for ($vsFrom = $lastVersionId; $vsFrom < $currentVersionId; $vsFrom += $versionBatchSize) {
// Don't go past the current version for atomicy.
$versionTo = min($currentVersionId, $vsFrom + $versionBatchSize);
$ids = array_map('intval', $this->getChangelog()->getList($vsFrom, $versionTo));
$versionTo = min($currentVersionId, $versionFrom + $versionBatchSize);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like $versionFrom is not defined there. Please fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'intval',
$this->productResource->getConnection()->fetchCol($unionSelect)
);
$this->categoryIdList[$productId] = array_map('intval', $this->productResource->getConnection()->fetchCol($unionSelect));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously code was the same as in 2.2-develop, so it's better to keep it as it was before. Please revert this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gelanivishal
Copy link
Contributor Author

@ihor-sviziev I have performed your requested changes.

@DanielRuf
Copy link
Contributor

Reverted? Does not seem so: https://github.com/magento/magento2/pull/18961/files

@gelanivishal
Copy link
Contributor Author

@DanielRuf Check now.

@@ -2021,11 +2021,7 @@ protected function _applyProductLimitations()
$this->getConnection()->quoteInto('cat_index.store_id=?', $filters['store_id'], 'int'),
];
if (isset($filters['visibility']) && !isset($filters['store_table'])) {
$conditions[] = $this->getConnection()->quoteInto(
Copy link
Contributor

@DanielRuf DanielRuf Nov 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not reverted here, please use the more readable version with multiple lines

@DanielRuf
Copy link
Contributor

In sum, there is currently no Ensure integer values are not quoted as strings. I highly advise not to hijack PRs of others and doing more changes. This here is not a forward port imho.

@orlangur orlangur self-assigned this Nov 7, 2018
@orlangur
Copy link
Contributor

orlangur commented Nov 7, 2018

@gelanivishal please fix this PR branch using force push so that it contains only two commits exactly as https://github.com/magento/magento2/pull/18287/commits preserving original authors. Otherwise we will have to reject such forwardport.

@ihor-sviziev ihor-sviziev removed their assignment Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants