-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix prune method #951
fix prune method #951
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see progress in #948
@willpower232 changes made, |
->delete() > 0; | ||
->get() | ||
->slice($threshold) | ||
->pluck($auditKeyName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that it is more efficient to put the pluck
above the slice
, replacing the get
src/Drivers/Database.php
Outdated
$forRemovalChunks = $forRemoval->chunk(Config::get('audit.placeholders_limit', 50000)); | ||
$answer = false; | ||
foreach ($forRemovalChunks as $chunk) { | ||
$answer = $answer || $model->audits() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I don't understand this,
after the first chunk
, answer
would be true
,
then in the second chunk(and later), the delete would no longer be executed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if the first chunk is executed, and the second for some reason is not, would it return true
even though only a portion of the records were deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any ideas? I thought if some deletion was performed in any case return true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to add tests to corroborate that the chunks are working.
->pluck($auditKeyName); | ||
|
||
if (!$forRemoval->isEmpty()) { | ||
$forRemovalChunks = $forRemoval->chunk(Config::get('audit.placeholders_limit', 50000)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have thousands of records, they will all be stored in memory as models, wouldn't that be less efficient than a leftJoin
?
Also, there would be two queries versus just one.
->latest() | ||
->offset($threshold)->limit(PHP_INT_MAX) | ||
->delete() > 0; | ||
->skip($threshold) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skip and take are alias of offset and limit
think this topic now is closed |
No description provided.