feat: add database indexes for frequent query patterns
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
index,
|
||||
pgEnum,
|
||||
pgTable,
|
||||
text,
|
||||
@@ -48,5 +49,6 @@ export const communitySuggestions = pgTable(
|
||||
table.fieldName,
|
||||
table.userId,
|
||||
),
|
||||
index("suggestions_status_idx").on(table.status),
|
||||
],
|
||||
)
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
boolean,
|
||||
index,
|
||||
pgTable,
|
||||
text,
|
||||
timestamp,
|
||||
@@ -21,5 +22,8 @@ export const gameVersions = pgTable(
|
||||
isLatest: boolean("is_latest").default(false).notNull(),
|
||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||
},
|
||||
(table) => [unique("game_build_unique").on(table.gameId, table.buildId)]
|
||||
(table) => [
|
||||
unique("game_build_unique").on(table.gameId, table.buildId),
|
||||
index("perf_game_lookup_idx").on(table.gameId),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -97,5 +97,8 @@ export const games = pgTable(
|
||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updated_at").defaultNow().notNull(),
|
||||
},
|
||||
(table) => [index("games_source_idx").on(table.source)],
|
||||
(table) => [
|
||||
index("games_source_idx").on(table.source),
|
||||
index("games_sync_status_idx").on(table.syncStatus, table.steamAppId),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -112,5 +112,7 @@ export const performanceEntries = pgTable(
|
||||
index("perf_hardware_upscaler_idx").on(table.hardwareSlug, table.upscalerType),
|
||||
index("perf_version_idx").on(table.versionId),
|
||||
index("perf_user_idx").on(table.userId),
|
||||
index("perf_removed_created_idx").on(table.isRemoved, table.createdAt.desc()),
|
||||
index("perf_upvotes_idx").on(table.upvotes.desc()),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
index,
|
||||
text,
|
||||
pgEnum,
|
||||
pgTable,
|
||||
@@ -37,4 +38,5 @@ export const reports = pgTable("reports", {
|
||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||
}, (table) => [
|
||||
uniqueIndex("reports_entry_reporter_unique").on(table.entryId, table.reporterId),
|
||||
index("reports_status_idx").on(table.status),
|
||||
])
|
||||
Reference in New Issue
Block a user