ssb: Mentions have become too slow. Using refs instead of fts seems better and faster, again?

This commit is contained in:
2025-11-29 15:37:17 -05:00
parent f4c6e2db1f
commit 89d3e9b4fe
2 changed files with 5 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
{ {
"type": "tildefriends-app", "type": "tildefriends-app",
"emoji": "🦀", "emoji": "🦀",
"previous": "&QPdP4BaztX9l3BBQNVbFAu8t5iN5NTqzhIOr+8bNhb0=.sha256" "previous": "&rjvfnAZ6XCB3JYO+Qtukpb5iYrbJ9niOLXCbbnQDmyY=.sha256"
} }

View File

@@ -118,10 +118,11 @@ class TfTabNewsFeedElement extends LitElement {
result = await tfrpc.rpc.query( result = await tfrpc.rpc.query(
` `
WITH mentions AS (SELECT messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature WITH mentions AS (SELECT messages.rowid, messages.id, messages.previous, messages.author, messages.sequence, messages.timestamp, messages.hash, json(messages.content) AS content, messages.signature
FROM messages_fts(?1) FROM messages_refs
JOIN messages ON messages.rowid = messages_fts.rowid JOIN messages ON messages.id = messages_refs.message
JOIN json_each(?2) AS following ON messages.author = following.value JOIN json_each(?2) AS following ON messages.author = following.value
WHERE WHERE
messages_refs.ref = ?1 AND
messages.author != ?1 AND messages.author != ?1 AND
(?3 IS NULL OR messages.timestamp >= ?3) AND messages.timestamp < ?4 (?3 IS NULL OR messages.timestamp >= ?3) AND messages.timestamp < ?4
ORDER BY timestamp DESC limit ?5) ORDER BY timestamp DESC limit ?5)
@@ -133,7 +134,7 @@ class TfTabNewsFeedElement extends LitElement {
SELECT TRUE AS is_primary, * FROM mentions SELECT TRUE AS is_primary, * FROM mentions
`, `,
[ [
'"' + this.whoami.replace('"', '""') + '"', this.whoami,
JSON.stringify(this.following), JSON.stringify(this.following),
start_time, start_time,
end_time, end_time,