#63669High memory consumption in DatabaseConnection->getDateTimeFormats while bulk inserting
Description
Multiple calls from
- sysext/backend/Classes/Form/DataPreprocessor.php
- sysext/backend/Classes/Utility/BackendUtility.php
- sysext/core/Classes/DataHandling/DataHandler.php
$dateTimeFormats = $GLOBALS['TYPO3_DB']->getDateTimeFormats($table);
Currently there is no table handling implemented, but for EACH CALL of every field of every record to insert a new array is generated:
public function getDateTimeFormats($table) {
return array(
'date' => array(
'empty' => '0000-00-00',
'format' => 'Y-m-d'
),
'datetime' => array(
'empty' => '0000-00-00 00:00:00',
'format' => 'Y-m-d H:i:s'
)
);
}
Instead of creating this array multiple times it should be created as a property of the class:
/**
* the date and time formats compatible with the database in general
*
* @var array
*/
protected $dateTimeFormats = array(
'date' => array(
'empty' => '0000-00-00',
'format' => 'Y-m-d'
),
'datetime' => array(
'empty' => '0000-00-00 00:00:00',
'format' => 'Y-m-d H:i:s'
)
);
public function getDateTimeFormats($table) {
return $this->dateTimeFormats;
}
For bulk insert of 6500 records:
- memory usage of getDateTimeFormats() down from 79MB to 2kB