# HG changeset patch # User Kim Alvefur # Date 1553217534 -3600 # Node ID 15270547c91c9a0ec36f92feba3f905e36ffce7c # Parent 4803a25c7e366f1712664e33249cb94a3b8eea6d mod_storage_sql: Return cached count if only this is queried for diff -r 4803a25c7e36 -r 15270547c91c plugins/mod_storage_sql.lua --- a/plugins/mod_storage_sql.lua Fri Mar 22 02:13:27 2019 +0100 +++ b/plugins/mod_storage_sql.lua Fri Mar 22 02:18:54 2019 +0100 @@ -362,7 +362,11 @@ function archive_store:find(username, query) query = query or {}; local user,store = username,self.store; - local total; + local cache_key = jid_join(username, host, self.store); + local total = archive_item_count_cache:get(cache_key); + if total ~= nil and query.limit == 0 and query.start == nil and query.with == nil and query["end"] == nil and query.key == nil then + return noop, total; + end local ok, result = engine:transaction(function() local sql_query = [[ SELECT "key", "type", "value", "when", "with"