further optimise federated deletes

This commit is contained in:
Mike Macgirvin 2022-07-11 15:33:21 -07:00
parent f1323ab130
commit 066e0cc9be

View file

@ -13,12 +13,18 @@ class Expire
cli_startup(); cli_startup();
// perform final cleanup on previously delete items // physically remove anything which has completed PHASE2 federated deletion
$r = q("delete from item where item_pending_remove = 1");
// Perform final cleanup on previously deleted items where
// DROPITEM_PHASE1 has completed and more than 4 days have elapsed
// so notifications should have been delivered.
$r = q( $r = q(
"select id from item where item_deleted = 1 and item_pending_remove = 0 and changed < %s - INTERVAL %s", "select id from item where item_deleted = 1 and item_pending_remove = 0 and changed < %s - INTERVAL %s",
db_utcnow(), db_utcnow(),
db_quoteinterval('10 DAY') db_quoteinterval('4 DAY')
); );
if ($r) { if ($r) {
foreach ($r as $rr) { foreach ($r as $rr) {
@ -26,15 +32,6 @@ class Expire
} }
} }
// physically remove anything that has been deleted for more than two months
/** @FIXME - this is a wretchedly inefficient query */
$r = q(
"delete from item where item_pending_remove = 1 and changed < %s - INTERVAL %s",
db_utcnow(),
db_quoteinterval('36 DAY')
);
logger('expire: start', LOGGER_DEBUG); logger('expire: start', LOGGER_DEBUG);
$site_expire = intval(get_config('system', 'default_expire_days')); $site_expire = intval(get_config('system', 'default_expire_days'));