core: batch load queues for subscriptions with PostgreSQL client (#6272)

* core: batch load queues for subscriptions with PostgreSQL client

* update simplexmq

* fix, update simplexmq

* update query plans
This commit is contained in:
Evgeny
2025-09-16 21:58:28 +01:00
committed by GitHub
parent 7c92c7666c
commit c07c176896
8 changed files with 35 additions and 84 deletions
+2 -2
View File
@@ -42,7 +42,7 @@ chatDbOptsP _appDir defaultDbName = do
( long "pool-size"
<> metavar "DB_POOL_SIZE"
<> help "Database connection pool size"
<> value 1
<> value 10
<> showDefault
)
dbCreateSchema <-
@@ -81,7 +81,7 @@ mobileDbOpts schemaPrefix connstr = do
ChatDbOpts
{ dbConnstr,
dbSchemaPrefix,
dbPoolSize = 1,
dbPoolSize = 10,
dbCreateSchema = True
}
@@ -327,16 +327,6 @@ Plan:
SEARCH r USING INTEGER PRIMARY KEY (rowid=?)
SEARCH s USING INTEGER PRIMARY KEY (rowid=?)
Query:
SELECT
user_id, conn_id, conn_mode, smp_agent_version, enable_ntfs,
last_external_snd_msg_id, deleted, ratchet_sync_state, pq_support
FROM connections
WHERE conn_id = ?
Plan:
SEARCH connections USING PRIMARY KEY (conn_id=?)
Query:
SELECT DISTINCT
s.xftp_host, s.xftp_port, s.xftp_key_hash
@@ -384,13 +374,13 @@ SEARCH s USING INTEGER PRIMARY KEY (rowid=?)
USE TEMP B-TREE FOR DISTINCT
Query:
SELECT DISTINCT c.host, c.port, COALESCE(c.server_key_hash, s.key_hash)
SELECT DISTINCT c.conn_id, c.host, c.port, COALESCE(c.server_key_hash, s.key_hash)
FROM commands c
LEFT JOIN servers s ON s.host = c.host AND s.port = c.port
WHERE conn_id = ?
ORDER BY c.conn_id
Plan:
SEARCH c USING INDEX idx_commands_conn_id (conn_id=?)
SCAN c USING INDEX idx_commands_conn_id
SEARCH s USING PRIMARY KEY (host=? AND port=?) LEFT-JOIN
USE TEMP B-TREE FOR DISTINCT
@@ -469,6 +459,15 @@ Plan:
SEARCH s USING PRIMARY KEY (conn_id=? AND internal_snd_id=?)
SEARCH m USING PRIMARY KEY (conn_id=? AND internal_id=?)
Query:
SELECT user_id, conn_id, conn_mode, smp_agent_version, enable_ntfs,
last_external_snd_msg_id, deleted, ratchet_sync_state, pq_support
FROM connections
WHERE conn_id = ? AND deleted = ?
Plan:
SEARCH connections USING PRIMARY KEY (conn_id=?)
Query:
DELETE FROM conn_confirmations
WHERE conn_id = ?