I have a table containing roughly 300k rows describing devices for Apple's Push Notification service. I use Doctrine 2 as an ORM.
Inserting devices is no problem, however, retrieving them is a whole different story. Using a simple MySQL SELECT
I can get them in a few seconds, where the WiFi is the main bottleneck. However, if I try to fetch them via Doctrine, it runs out of memory even if I allow PHP up to 1 gigabyte. I have created getters and setters and protected properties for the Doctrine entities, as per the documentation.
I have no clue what I'm doing wrong. This is fine:
$devices = mysql_query("SELECT * FROM `Devices` WHERE `deviceProperty`='someValue'");
$message = new Message();
while($device = mysql_fetch_array($devices))
{
$message->addRecipient($device['pushToken']);
}
but this runs out of memory on the first line (it never reaches a breakpoint on the next line):
$devices = self::$entityManager->getRepository('Device')->findBy(array("deviceProperty" => "someValue"));
$message = new Message();
foreach($devices as $device)
{
$message->addRecipient($device->getPushToken);
}