diff --git a/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php b/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php
index d751fdc75882d7514e282ad95908ffa74c86e65c..53c4605a819132df0791df60edb325ed5cf5837c 100644
--- a/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php
+++ b/app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php
@@ -542,19 +542,24 @@ class AdvancedPricing extends \Magento\ImportExport\Model\Import\Entity\Abstract
      */
     protected function processCountExistingPrices($prices, $table)
     {
+        $oldSkus = $this->retrieveOldSkus();
+        $existProductIds = array_intersect_key($oldSkus, $prices);
+        if (!count($existProductIds)) {
+            return $this;
+        }
+
         $tableName = $this->_resourceFactory->create()->getTable($table);
         $productEntityLinkField = $this->getProductEntityLinkField();
         $existingPrices = $this->_connection->fetchAssoc(
             $this->_connection->select()->from(
                 $tableName,
                 ['value_id', $productEntityLinkField, 'all_groups', 'customer_group_id']
-            )
+            )->where($productEntityLinkField . ' IN (?)', $existProductIds)
         );
-        $oldSkus = $this->retrieveOldSkus();
         foreach ($existingPrices as $existingPrice) {
-            foreach ($oldSkus as $sku => $productId) {
-                if ($existingPrice[$productEntityLinkField] == $productId && isset($prices[$sku])) {
-                    $this->incrementCounterUpdated($prices[$sku], $existingPrice);
+            foreach ($prices as $sku => $skuPrices) {
+                if (isset($oldSkus[$sku]) && $existingPrice[$productEntityLinkField] == $oldSkus[$sku]) {
+                    $this->incrementCounterUpdated($skuPrices, $existingPrice);
                 }
             }
         }