Improve query speed

This commit is contained in:
Michael 2018-10-24 04:50:27 +00:00
parent c0a24d80dd
commit a6f6db8d4e

View File

@ -16,13 +16,13 @@ class RemoveContact {
// Only delete if the contact is to be deleted // Only delete if the contact is to be deleted
$condition = ['network' => Protocol::PHANTOM, 'id' => $id]; $condition = ['network' => Protocol::PHANTOM, 'id' => $id];
$r = DBA::exists('contact', $condition); $contact = DBA::selectFirst('contact', ['uid'], $condition);
if (!DBA::isResult($r)) { if (!DBA::isResult($contact)) {
return; return;
} }
// Now we delete the contact and all depending tables // Now we delete the contact and all depending tables
$condition = ['contact-id' => $id]; $condition = ['uid' => $contact['uid'], 'contact-id' => $id];
do { do {
$items = Item::select(['id'], $condition, ['limit' => 100]); $items = Item::select(['id'], $condition, ['limit' => 100]);
while ($item = Item::fetch($items)) { while ($item = Item::fetch($items)) {