aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-07-06 22:19:05 -0700
committerredmatrix <git@macgirvin.com>2016-07-06 22:19:05 -0700
commit3bee6543fbd339adf9b9993269b6a46bec27f05e (patch)
tree87cd13b69e45230d5007a778250a49e969e287ba /include
parent581a3c532303c008390a2851a1e42c6f5de390b1 (diff)
downloadvolse-hubzilla-3bee6543fbd339adf9b9993269b6a46bec27f05e.tar.gz
volse-hubzilla-3bee6543fbd339adf9b9993269b6a46bec27f05e.tar.bz2
volse-hubzilla-3bee6543fbd339adf9b9993269b6a46bec27f05e.zip
reduce the memory usage of the expire query dramatically.
Diffstat (limited to 'include')
-rwxr-xr-xinclude/items.php29
1 files changed, 10 insertions, 19 deletions
diff --git a/include/items.php b/include/items.php
index fd0cfff32..72f0896ad 100755
--- a/include/items.php
+++ b/include/items.php
@@ -3282,19 +3282,21 @@ function item_expire($uid,$days) {
$expire_limit = get_config('system','expire_limit');
if(! intval($expire_limit))
- $expire_limit = 2500;
+ $expire_limit = 5000;
$item_normal = item_normal();
- $r = q("SELECT * FROM `item`
- WHERE `uid` = %d
- AND `created` < %s - INTERVAL %s
- AND `id` = `parent`
- $sql_extra
+ $r = q("SELECT id FROM item
+ WHERE uid = %d
+ AND created < %s - INTERVAL %s
AND item_retained = 0
- $item_normal LIMIT $expire_limit ",
+ AND item_thread_top = 1
+ AND resource_type = ''
+ AND item_starred = 0
+ $sql_extra $item_normal LIMIT $expire_limit ",
intval($uid),
- db_utcnow(), db_quoteinterval(intval($days).' DAY')
+ db_utcnow(),
+ db_quoteinterval(intval($days).' DAY')
);
if(! $r)
@@ -3312,17 +3314,6 @@ function item_expire($uid,$days) {
continue;
}
- // Only expire posts, not photos and photo comments
-
- if($item['resource_type'] === 'photo') {
- retain_item($item['id']);
- continue;
- }
- if(intval($item['item_starred'])) {
- retain_item($item['id']);
- continue;
- }
-
drop_item($item['id'],false);
}