# HG changeset patch # User Kim Alvefur # Date 1493199982 -7200 # Node ID 6ddddfe05a745ba9684f1a40543147036e68f228 # Parent c8e3a0caa0a9385a3a0110459c79a09b63b8b7a3 mod_mam: Don't ask the storage backend to count all items when expiry is disabled diff -r c8e3a0caa0a9 -r 6ddddfe05a74 plugins/mod_mam/mod_mam.lua --- a/plugins/mod_mam/mod_mam.lua Tue Apr 25 21:50:36 2017 +0200 +++ b/plugins/mod_mam/mod_mam.lua Wed Apr 26 11:46:22 2017 +0200 @@ -52,6 +52,8 @@ archive = module:require "fallback_archive"; end +local use_total = true; + local cleanup; -- Handle prefs. @@ -137,7 +139,7 @@ limit = qmax + 1; before = before; after = after; reverse = reverse; - total = true; + total = get_total; }); if not data then @@ -359,6 +361,10 @@ end return math.random(cleanup_interval, cleanup_interval * 2); end); +else + -- Don't ask the backend to count the potentially unbounded number of items, + -- it'll get slow. + use_total = false; end -- Stanzas sent by local clients