diff --git a/.config/example.yml b/.config/example.yml index 5f65ea96a7..6c3e0cab57 100644 --- a/.config/example.yml +++ b/.config/example.yml @@ -80,8 +80,10 @@ db: # sparseTimelineDays: 14 # # # determines the number of maximum rows read within one pagination. -# # (default 1000, max 5000, min 1) -# queryLimit: 1000 +# # You may need to make [max_clustering_key_restrictions_per_query] bigger for ScyllaDB +# # if you want to set this value larger than 100. +# # (default 100, max 5000, min 1) +# queryLimit: 100 # ┌─────────────────────┐ #───┘ Redis configuration └───────────────────────────────────── diff --git a/packages/backend/src/db/scylla.ts b/packages/backend/src/db/scylla.ts index fc8130997a..01e765a6a8 100644 --- a/packages/backend/src/db/scylla.ts +++ b/packages/backend/src/db/scylla.ts @@ -437,7 +437,7 @@ export async function execPaginationQuery( let scannedPartitions = 0; const found: ScyllaNote[] | ScyllaNotification[] | ScyllaNoteReaction[] = []; - const queryLimit = config.scylla?.queryLimit ?? 1000; + const queryLimit = config.scylla?.queryLimit ?? 100; let foundLimit = ps.limit; if (kind === "list" && ps.userIds) { foundLimit *= ps.userIds.length; @@ -468,7 +468,7 @@ export async function execPaginationQuery( params.push(sinceDate); } - const fetchLimit = kind === "list" ? ps.limit : queryLimit; + const fetchLimit = kind === "list" && ps.limit < 100 ? ps.limit : queryLimit; params.push(fetchLimit); const result = await scyllaClient.execute(query, params, { diff --git a/packages/backend/src/server/api/endpoints/users/reactions.ts b/packages/backend/src/server/api/endpoints/users/reactions.ts index 3c8dfbc005..722cf0126f 100644 --- a/packages/backend/src/server/api/endpoints/users/reactions.ts +++ b/packages/backend/src/server/api/endpoints/users/reactions.ts @@ -12,6 +12,7 @@ import { scyllaClient, } from "@/db/scylla.js"; import { LocalFollowingsCache } from "@/misc/cache.js"; +import type { Client } from "cassandra-driver"; export const meta = { tags: ["users", "reactions"], @@ -63,6 +64,8 @@ export default define(meta, paramDef, async (ps, me) => { } if (scyllaClient) { + const client: Client = scyllaClient + let followingUserIds: string[] = []; if (me) { followingUserIds = await LocalFollowingsCache.init(me.id).then((cache) => @@ -71,10 +74,9 @@ export default define(meta, paramDef, async (ps, me) => { } const filter = async (reactions: ScyllaNoteReaction[]) => { - if (!scyllaClient) return reactions; let noteIds = reactions.map(({ noteId }) => noteId); if (me) { - const notes = await scyllaClient + const notes = await client .execute(prepared.note.select.byIds, [noteIds], { prepare: true }) .then((result) => result.rows.map(parseScyllaNote)); const filteredNoteIds = await filterVisibility(