feat: add database indexes for frequent query patterns
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
|
index,
|
||||||
pgEnum,
|
pgEnum,
|
||||||
pgTable,
|
pgTable,
|
||||||
text,
|
text,
|
||||||
@@ -48,5 +49,6 @@ export const communitySuggestions = pgTable(
|
|||||||
table.fieldName,
|
table.fieldName,
|
||||||
table.userId,
|
table.userId,
|
||||||
),
|
),
|
||||||
|
index("suggestions_status_idx").on(table.status),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
boolean,
|
boolean,
|
||||||
|
index,
|
||||||
pgTable,
|
pgTable,
|
||||||
text,
|
text,
|
||||||
timestamp,
|
timestamp,
|
||||||
@@ -21,5 +22,8 @@ export const gameVersions = pgTable(
|
|||||||
isLatest: boolean("is_latest").default(false).notNull(),
|
isLatest: boolean("is_latest").default(false).notNull(),
|
||||||
createdAt: timestamp("created_at").defaultNow().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(),
|
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||||
updatedAt: timestamp("updated_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_hardware_upscaler_idx").on(table.hardwareSlug, table.upscalerType),
|
||||||
index("perf_version_idx").on(table.versionId),
|
index("perf_version_idx").on(table.versionId),
|
||||||
index("perf_user_idx").on(table.userId),
|
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 {
|
import {
|
||||||
|
index,
|
||||||
text,
|
text,
|
||||||
pgEnum,
|
pgEnum,
|
||||||
pgTable,
|
pgTable,
|
||||||
@@ -37,4 +38,5 @@ export const reports = pgTable("reports", {
|
|||||||
createdAt: timestamp("created_at").defaultNow().notNull(),
|
createdAt: timestamp("created_at").defaultNow().notNull(),
|
||||||
}, (table) => [
|
}, (table) => [
|
||||||
uniqueIndex("reports_entry_reporter_unique").on(table.entryId, table.reporterId),
|
uniqueIndex("reports_entry_reporter_unique").on(table.entryId, table.reporterId),
|
||||||
|
index("reports_status_idx").on(table.status),
|
||||||
])
|
])
|
||||||
Reference in New Issue
Block a user