Skip to content

Commit 650a4a1

Browse files
author
Oleksandr Iegorov
committed
MC-19791: Poor performance on sales order update - string to integer
1 parent 156c5f2 commit 650a4a1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/internal/Magento/Framework/Model/ResourceModel/Db/AbstractDb.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -793,10 +793,15 @@ protected function saveNewObject(\Magento\Framework\Model\AbstractModel $object)
793793
*/
794794
protected function updateObject(\Magento\Framework\Model\AbstractModel $object)
795795
{
796-
//quoting numeric values as strings may decrease query performance on some environments
797-
$condition = is_numeric($object->getId())
798-
? $this->getIdFieldName() . '=' . (int) $object->getId()
799-
: $this->getConnection()->quoteInto($this->getIdFieldName() . '=?', $object->getId());
796+
$tableDescription = $this->getConnection()
797+
->describeTable($this->getMainTable());
798+
$preparedValue = $this->getConnection()
799+
->prepareColumnValue(
800+
$tableDescription[$this->getIdFieldName()],
801+
$object->getId()
802+
);
803+
$condition = $this->getIdFieldName() . '=' . $preparedValue;
804+
800805
/**
801806
* Not auto increment primary key support
802807
*/

0 commit comments

Comments
 (0)