ssb: Still chasing faster loads of the default news query.

This commit is contained in:
2025-04-02 12:44:17 -04:00
parent c128cfc25c
commit 894c72a82f
3 changed files with 13 additions and 5 deletions

View File

@ -1,5 +1,5 @@
{
"type": "tildefriends-app",
"emoji": "🦀",
"previous": "&U/Hy2rgSqwKeF30kKWPUL0qLzXBnxPHxQS5OgfxwZG8=.sha256"
"previous": "&BNj/9Tct9Iw03fAx0TSjCI5Cm1EizcmTj6JZm3bZpB4=.sha256"
}

View File

@ -159,13 +159,15 @@ class TfTabNewsFeedElement extends LitElement {
);
result = (await this.decrypt(result)).filter((x) => x.decrypted);
} else {
let st = new Date();
result = await tfrpc.rpc.query(
`
WITH
all_news 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
JOIN json_each(?) AS following ON messages.author = following.value),
JOIN json_each(?) AS following ON messages.author = following.value
),
news AS (
SELECT * FROM all_news
WHERE all_news.timestamp < ?3 AND (?2 IS NULL OR all_news.timestamp >= ?2)
@ -183,6 +185,10 @@ class TfTabNewsFeedElement extends LitElement {
`,
[JSON.stringify(this.following), start_time, end_time]
);
let et = new Date();
console.log(
`just the load of ${result.length} rows = ${(et - st) / 1000} following=${this.following.length} st=${start_time} et=${end_time}`
);
}
this.time_loading = undefined;
return result;
@ -308,7 +314,7 @@ class TfTabNewsFeedElement extends LitElement {
this.messages = this.merge_messages(this.messages, messages);
this.time_loading = undefined;
console.log(
`loading messages done for ${self.whoami} in ${(new Date() - start_time) / 1000}s`
`loading ${messages.length} messages done for ${self.whoami} in ${(new Date() - start_time) / 1000}s`
);
}