# HG changeset patch # User Kim Alvefur # Date 1396977791 -7200 # Node ID de4c83feb06413bd8add98b172f21057dc50b352 # Parent 1607b03356ed8ecb4addc65ef392d841598823d6 mod_storage_sql2: Build counter query without ORDER BY clause diff -r 1607b03356ed -r de4c83feb064 plugins/mod_storage_sql2.lua --- a/plugins/mod_storage_sql2.lua Thu Apr 03 23:48:12 2014 +0200 +++ b/plugins/mod_storage_sql2.lua Tue Apr 08 19:23:11 2014 +0200 @@ -289,7 +289,7 @@ -- Total matching if query.total then - local stats = engine:select(sql_query:gsub("^(SELECT).-(FROM)", "%1 COUNT(*) %2"):format(t_concat(where, " AND "), "DESC", ""), unpack(args)); + local stats = engine:select("SELECT COUNT(*) FROM `prosodyarchive` WHERE " .. t_concat(where, " AND "), unpack(args)); if stats then local _total = stats() total = _total and _total[1];