Optimize removeKnownAttachments
This commit is contained in:
parent
4d180a26fe
commit
dddb3129cc
1 changed files with 27 additions and 27 deletions
|
@ -6182,7 +6182,7 @@ async function removeKnownAttachments(
|
||||||
const lookup: Dictionary<boolean> = fromPairs(
|
const lookup: Dictionary<boolean> = fromPairs(
|
||||||
map(allAttachments, file => [file, true])
|
map(allAttachments, file => [file, true])
|
||||||
);
|
);
|
||||||
const chunkSize = 50;
|
const chunkSize = 500;
|
||||||
|
|
||||||
const total = await getMessageCount();
|
const total = await getMessageCount();
|
||||||
logger.info(
|
logger.info(
|
||||||
|
@ -6193,17 +6193,17 @@ async function removeKnownAttachments(
|
||||||
let complete = false;
|
let complete = false;
|
||||||
let id: string | number = '';
|
let id: string | number = '';
|
||||||
|
|
||||||
while (!complete) {
|
const fetchMessages = db.prepare<Query>(
|
||||||
const rows: JSONRows = db
|
|
||||||
.prepare<Query>(
|
|
||||||
`
|
`
|
||||||
SELECT json FROM messages
|
SELECT json FROM messages
|
||||||
WHERE id > $id
|
WHERE id > $id
|
||||||
ORDER BY id ASC
|
ORDER BY id ASC
|
||||||
LIMIT $chunkSize;
|
LIMIT $chunkSize;
|
||||||
`
|
`
|
||||||
)
|
);
|
||||||
.all({
|
|
||||||
|
while (!complete) {
|
||||||
|
const rows: JSONRows = fetchMessages.all({
|
||||||
id,
|
id,
|
||||||
chunkSize,
|
chunkSize,
|
||||||
});
|
});
|
||||||
|
@ -6239,17 +6239,17 @@ async function removeKnownAttachments(
|
||||||
`removeKnownAttachments: About to iterate through ${conversationTotal} conversations`
|
`removeKnownAttachments: About to iterate through ${conversationTotal} conversations`
|
||||||
);
|
);
|
||||||
|
|
||||||
while (!complete) {
|
const fetchConversations = db.prepare<Query>(
|
||||||
const rows = db
|
|
||||||
.prepare<Query>(
|
|
||||||
`
|
`
|
||||||
SELECT json FROM conversations
|
SELECT json FROM conversations
|
||||||
WHERE id > $id
|
WHERE id > $id
|
||||||
ORDER BY id ASC
|
ORDER BY id ASC
|
||||||
LIMIT $chunkSize;
|
LIMIT $chunkSize;
|
||||||
`
|
`
|
||||||
)
|
);
|
||||||
.all({
|
|
||||||
|
while (!complete) {
|
||||||
|
const rows = fetchConversations.all({
|
||||||
id,
|
id,
|
||||||
chunkSize,
|
chunkSize,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue