Add an index of columns user_id and created_at to the library_item table for counting query

This commit is contained in:
Hongbo Wu 2024-07-25 11:18:52 +08:00
parent 6f12b5e406
commit 465e5dc7d1
3 changed files with 17 additions and 3 deletions

View file

@ -760,7 +760,7 @@ export const bulkActionResolver = authorized<
},
})
const batchSize = 50
const batchSize = 20
const searchArgs = {
query,
includePending: true,
@ -779,13 +779,13 @@ export const bulkActionResolver = authorized<
action,
count,
})
// if there are less than 50 items, update them synchronously
// if there are less than batchSize items, update them synchronously
await batchUpdateLibraryItems(action, searchArgs, uid, labelIds, args)
return { success: true }
}
// if there are more than 50 items, update them asynchronously
// if there are more than batchSize items, update them asynchronously
const data = {
userId: uid,
action,

View file

@ -0,0 +1,5 @@
-- Type: DO
-- Name: add_user_id_created_at_index_to_library_item
-- Description: Add an index of columns user_id and created_at to the library_item table for counting query
CREATE INDEX CONCURRENTLY IF NOT EXISTS library_item_user_id_created_at_idx ON omnivore.library_item (user_id, created_at);

View file

@ -0,0 +1,9 @@
-- Type: UNDO
-- Name: add_user_id_created_at_index_to_library_item
-- Description: Add an index of columns user_id and created_at to the library_item table for counting query
BEGIN;
DROP INDEX IF EXISTS omnivore.library_item_user_id_created_at_idx;
COMMIT;