comparison plugins/mod_storage_sql.lua @ 14002:f82be93b61a5

mod_storage_sql: optimization: use table.move for copying items between arrays
author Matthew Wild <mwild1@gmail.com>
date Sat, 06 Dec 2025 15:58:40 +0000
parents 1b300c5a79d7
children
comparison
equal deleted inserted replaced
14001:df970d2dac45 14002:f82be93b61a5
8 local resolve_relative_path = require "prosody.util.paths".resolve_relative_path; 8 local resolve_relative_path = require "prosody.util.paths".resolve_relative_path;
9 local jid_join = require "prosody.util.jid".join; 9 local jid_join = require "prosody.util.jid".join;
10 10
11 local is_stanza = require"prosody.util.stanza".is_stanza; 11 local is_stanza = require"prosody.util.stanza".is_stanza;
12 local t_concat = table.concat; 12 local t_concat = table.concat;
13 local t_move = require "prosody.util.table".move;
13 14
14 local have_dbisql, dbisql = pcall(require, "prosody.util.sql"); 15 local have_dbisql, dbisql = pcall(require, "prosody.util.sql");
15 local have_sqlite, sqlite = pcall(require, "prosody.util.sqlite3"); 16 local have_sqlite, sqlite = pcall(require, "prosody.util.sqlite3");
16 if not (have_dbisql or have_sqlite) then 17 if not (have_dbisql or have_sqlite) then
17 module:log("error", "LuaDBI or LuaSQLite3 are required for using SQL databases but neither are installed"); 18 module:log("error", "LuaDBI or LuaSQLite3 are required for using SQL databases but neither are installed");
428 429
429 -- Set of ids 430 -- Set of ids
430 if query.ids then 431 if query.ids then
431 local nids, nargs = #query.ids, #args; 432 local nids, nargs = #query.ids, #args;
432 where[#where + 1] = "\"key\" IN (" .. string.rep("?", nids, ",") .. ")"; 433 where[#where + 1] = "\"key\" IN (" .. string.rep("?", nids, ",") .. ")";
433 for i, id in ipairs(query.ids) do 434 t_move(query.ids, 1, nids, nargs + 1, args);
434 args[nargs+i] = id;
435 end
436 end 435 end
437 end 436 end
438 local function archive_where_id_range(query, args, where) 437 local function archive_where_id_range(query, args, where)
439 -- Before or after specific item, exclusive 438 -- Before or after specific item, exclusive
440 local id_lookup_sql = [[ 439 local id_lookup_sql = [[