I'm execuiting a simple query with sqlsrv driver for PHP returning 104586 rows x 30 columns as follows:
$sql = 'SELECT [columns] FROM [table]'
$stmt = sqlsrv_query($conn, $sql, $params);
while($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC)) {
$dataSet[] = $row;
}
If I echo all the $row
everything works and page loads in 4-5 seconds but if try to assign them to an array, PHP runs out of memory error with the following message in the log file:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)
I need data in array format for further usage. Is there a more efficient way of obtaining this? Am I missing somenthing?
Executing the query with SSMS takes 2 seconds, so there's nothing heavy in it.
PHP version is 7.0.23 if this might matter.