fix(server): index hot Postgres query paths (#2218)

This commit is contained in:
RainbowBird
2026-08-04 21:24:26 +08:00
committed by GitHub
parent e6ca9750b4
commit 2abb1ac9ff
6 changed files with 3679 additions and 5 deletions
-4
View File
@@ -49,10 +49,6 @@ export default defineConfig({
// default no-restricted-syntax patterns are preserved alongside.
'no-restricted-syntax': [
'error',
{
selector: 'TSImportType',
message: 'Do not use inline type imports. Import types explicitly from their owning module, or split a dedicated side-effect-free type module when a runtime import would pull in the wrong environment.',
},
{
selector: 'ConditionalExpression[test.type=\'BinaryExpression\'][test.operator=\'instanceof\'][test.right.name=\'Error\'][consequent.type=\'MemberExpression\'][consequent.property.name=\'message\']',
message: 'Avoid `error instanceof Error ? error.message : ...`. Use `errorMessageFrom(error)` from \'@moeru/std\' (or `errorMessageFromUnknown(error, fallback)` from \'@proj-airi/stage-shared\'). Pair with `?? \'fallback\'` when a default is needed.',
@@ -0,0 +1,2 @@
CREATE INDEX IF NOT EXISTS "messages_chat_id_seq_idx" ON "messages" USING btree ("chat_id","seq");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "account_account_id_provider_id_idx" ON "account" USING btree ("account_id","provider_id");
File diff suppressed because it is too large Load Diff
@@ -134,6 +134,13 @@
"when": 1785833974268,
"tag": "0018_blushing_scarlet_witch",
"breakpoints": true
},
{
"idx": 19,
"version": "7",
"when": 1785843526589,
"tag": "0019_low_namora",
"breakpoints": true
}
]
}
+4 -1
View File
@@ -80,7 +80,10 @@ export const account = pgTable(
.$onUpdate(() => /* @__PURE__ */ new Date())
.notNull(),
},
table => [index('account_userId_idx').on(table.userId)],
table => [
index('account_userId_idx').on(table.userId),
index('account_account_id_provider_id_idx').on(table.accountId, table.providerId),
],
)
export const verification = pgTable(
+1
View File
@@ -95,6 +95,7 @@ export const messages = pgTable(
deletedAt: timestamp('deleted_at'),
},
table => [
index('messages_chat_id_seq_idx').on(table.chatId, table.seq),
index('messages_chat_id_seq_active_idx')
.on(table.chatId, table.seq)
.where(sql`${table.deletedAt} IS NULL`),