Log message #4183931

# At Username Text
# Apr 18th 2019, 17:34 ricksaccous thanks
# Apr 18th 2019, 17:33 ricksaccous interesting, i'll consider this if i run into bottlenecks
# Apr 18th 2019, 17:33 admad update or insert depending on what you need
# Apr 18th 2019, 17:33 admad use what i linked above
# Apr 18th 2019, 17:32 ricksaccous @admad speaking of i have a point where i might be patching in 400 records.... do you recommend saving that instead with raw sql if possible?
# Apr 18th 2019, 17:31 admad https://book.cakephp.org/3.0/en/orm/query-builder.html#inserting-data
# Apr 18th 2019, 17:31 ricksaccous yeah ;)
# Apr 18th 2019, 17:31 ricksaccous using the ORM to just build the raw save query
# Apr 18th 2019, 17:31 pedrorocha Unfortunately I'm using cakephp 3.1 and I'm afraid I can upgrade it in production.. Can it be done in cakephp 3.1?
# Apr 18th 2019, 17:31 ricksaccous and probably skipping to raw sql saves is faster
# Apr 18th 2019, 17:30 ricksaccous i'd just be worried about the patchEntities anyway
# Apr 18th 2019, 17:30 admad ORM methods are meant for bulk saves anyway. Use lower level db methods
# Apr 18th 2019, 17:30 ricksaccous no you'd have to do a saveMany
# Apr 18th 2019, 17:30 pedrorocha ->save() accepts my whole array of data?
# Apr 18th 2019, 17:29 ricksaccous in one query
# Apr 18th 2019, 17:29 ricksaccous @pedrorocha why not save 15k per loop pass
# Apr 18th 2019, 17:27 slackebot loop memory usage run: 10 -> 2.69 MB Inner loop memory usage run: 11 -> 2.69 MB Inner loop memory usage run: 12 -> 2.48 MB Total loop memory usage -> 2.41 MB Why is this happening? How can I free the memory used by the inner loop on each run?
# Apr 18th 2019, 17:27 slackebot I comment the `->save()` line, it looks like this (as it should be): Inner loop memory usage run: 1 -> 2.66 MB Inner loop memory usage run: 2 -> 2.68 MB Inner loop memory usage run: 3 -> 2.69 MB Inner loop memory usage run: 4 -> 2.69 MB Inner loop memory usage run: 5 -> 2.69 MB Inner loop memory usage run: 6 -> 2.69 MB Inner loop memory usage run: 7 -> 2.69 MB Inner loop memory usage run: 8 -> 2.69 MB Inner loop memory usage run: 9 -> 2.69 MB Inner
# Apr 18th 2019, 17:27 slackebot -> 23.52 MB Inner loop memory usage run: 5 -> 29.82 MB Inner loop memory usage run: 6 -> 38.11 MB Inner loop memory usage run: 7 -> 44.41 MB Inner loop memory usage run: 8 -> 50.7 MB Inner loop memory usage run: 9 -> 56.99 MB Inner loop memory usage run: 10 -> 67.29 MB Inner loop memory usage run: 11 -> 73.58 MB Inner loop memory usage run: 12 -> 79.67 MB Total loop memory usage -> 82.13 MB It should not be wasting this much memory on each loop, when
# Apr 18th 2019, 17:27 pedrorocha Hello guys, I'm trying to save 320k records on my db using a foreach loop to iterate through an array of data. I loaded the model outside the loop and split the data in batches of 15k, the inner loop looks like this: ```foreach ($users as $user) { $dataToSave = array('user_id' => $user->id, 'notification_id' => $notificationId); $userNotification = $this->UserNotification->newEntity(); $userNotification =
# Apr 18th 2019, 17:27 slackebot $this->UserNotification->patchEntity($userNotification, $dataToSave); $this->UserNotification->save($userNotification); }``` It's wrapped around a while loop counting the number of runs and managing the batches. When I run this code and track the memory usage of it, this is what I'm getting: Inner loop memory usage run: 1 -> 2.61 MB Inner loop memory usage run: 2 -> 9.43 MB Inner loop memory usage run: 3 -> 16.23 MB Inner loop memory usage run: 4
# Apr 18th 2019, 16:32 admad @mrfeedback `<?=` is short echo, different than short open tag. It's unaffected by php config and always available
# Apr 18th 2019, 16:20 mrfeedback `Note that this directive does not control the <?= shorthand tag, which can be ; used regardless of this directive.`
# Apr 18th 2019, 16:20 mrfeedback oh. okay forget what i said
# Apr 18th 2019, 16:18 mrfeedback yep i mean `<?=` as `short_tag_open` is also not recommened as `On` for production environments according to the official php.ini https://github.com/php/php-src/blob/master/php.ini-production
# Apr 18th 2019, 16:14 ricksaccous the second is never used
# Apr 18th 2019, 16:13 ricksaccous @mrfeedback <?= is very distinct from <? ?>
# Apr 18th 2019, 16:13 waspinator never heard of it being a problem before
# Apr 18th 2019, 16:13 waspinator you mean this `<?=`
# Apr 18th 2019, 16:11 waspinator https://github.com/cakephp/cakephp.org/blob/master/src/Template/Element/Layout/default/footer/social_links.ctp
# Apr 18th 2019, 16:09 mrfeedback i mean its used everywhere as it seems :slightly_smiling_face:
# Apr 18th 2019, 16:09 mrfeedback cakephp.org\src\Template\Element\Layout\default\footer\social_links.ctp e.g.
# Apr 18th 2019, 16:08 admad where?
# Apr 18th 2019, 16:08 mrfeedback hmm browsing through templates of cakephp.org i realize that you use shorttags for opening and echoing in php. i was told that this feature is often disabled on hosts due to security concerns. or is this not an actual problem anymore?
# Apr 18th 2019, 16:07 admad then make a PR for the docs :slightly_smiling_face:
# Apr 18th 2019, 16:02 mrfeedback ah funny. on the website itself it is removed. but not in the book
# Apr 18th 2019, 15:56 mrfeedback thx
# Apr 18th 2019, 15:50 admad https://github.com/cakephp/cakephp.org
# Apr 18th 2019, 15:49 mrfeedback hmm i have no idea where to put the PR for the website? :slightly_smiling_face:
# Apr 18th 2019, 15:45 admad @mrfeedback make a PR :slightly_smiling_face:
# Apr 18th 2019, 15:42 mrfeedback i think you can remove the Google+ Button on the website :)