Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MaxHeapTableSizeProcessor.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
20  protected $connection;
21 
26 
32  protected $currentMaxHeapTableSize = null;
33 
38  {
39  $this->connection = $resource->getConnection();
40  $this->defaultMaxHeapTableSie = 1024 * 1024 * 64;
41  }
42 
51  public function set($maxHeapTableSize = null)
52  {
53  $maxHeapTableSize = (int) (null === $maxHeapTableSize ? $this->defaultMaxHeapTableSie : $maxHeapTableSize);
54  if (!$maxHeapTableSize) {
55  throw new \InvalidArgumentException('Wrong max_heap_table_size parameter');
56  }
57 
58  $this->currentMaxHeapTableSize = (int)$this->connection->fetchOne('SELECT @@session.max_heap_table_size');
59  if (!$this->currentMaxHeapTableSize) {
60  throw new \RuntimeException('Can not extract max_heap_table_size');
61  }
62 
63  $this->connection->query('SET SESSION max_heap_table_size = ' . $maxHeapTableSize);
64  }
65 
72  public function restore()
73  {
74  if (null === $this->currentMaxHeapTableSize) {
75  throw new \RuntimeException('max_heap_table_size parameter is not set');
76  }
77  $this->connection->query('SET SESSION max_heap_table_size = ' . $this->currentMaxHeapTableSize);
78  }
79 }
$resource
Definition: bulk.php:12