Refine audit and rank tracking indexes (#378)

This commit is contained in:
Ben Senescu 2026-07-10 12:21:56 -04:00 committed by Ben Senescu
parent d7b52f0876
commit e264ee3472
10 changed files with 6507 additions and 12 deletions

View File

@ -0,0 +1,4 @@
DROP INDEX "audit_issues_audit_id_idx";--> statement-breakpoint
DROP INDEX "audit_links_audit_id_idx";--> statement-breakpoint
DROP INDEX "audit_pages_audit_id_idx";--> statement-breakpoint
CREATE INDEX "rank_tracking_configs_project_active_created_idx" ON "rank_tracking_configs" USING btree ("project_id","is_active","created_at");

File diff suppressed because it is too large Load Diff

View File

@ -64,6 +64,13 @@
"when": 1783630716543, "when": 1783630716543,
"tag": "0008_yummy_annihilus", "tag": "0008_yummy_annihilus",
"breakpoints": true "breakpoints": true
},
{
"idx": 9,
"version": "7",
"when": 1783699015488,
"tag": "0009_supreme_captain_stacy",
"breakpoints": true
} }
] ]
} }

View File

@ -0,0 +1,4 @@
DROP INDEX `audit_issues_audit_id_idx`;--> statement-breakpoint
DROP INDEX `audit_links_audit_id_idx`;--> statement-breakpoint
DROP INDEX `audit_pages_audit_id_idx`;--> statement-breakpoint
CREATE INDEX `rank_tracking_configs_project_active_created_idx` ON `rank_tracking_configs` (`project_id`,`is_active`,`created_at`);

File diff suppressed because it is too large Load Diff

View File

@ -225,6 +225,13 @@
"when": 1783630714621, "when": 1783630714621,
"tag": "0031_furry_monster_badoon", "tag": "0031_furry_monster_badoon",
"breakpoints": true "breakpoints": true
},
{
"idx": 32,
"version": "6",
"when": 1783699001850,
"tag": "0032_public_shinko_yamashiro",
"breakpoints": true
} }
] ]
} }

View File

@ -235,6 +235,11 @@ export const rankTrackingConfigs = sqliteTable(
.default(sql`(current_timestamp)`), .default(sql`(current_timestamp)`),
}, },
(table) => [ (table) => [
index("rank_tracking_configs_project_active_created_idx").on(
table.projectId,
table.isActive,
table.createdAt,
),
uniqueIndex("rank_tracking_configs_national_idx") uniqueIndex("rank_tracking_configs_national_idx")
.on(table.projectId, table.domain, table.locationCode) .on(table.projectId, table.domain, table.locationCode)
.where(sql`${table.locationName} IS NULL`), .where(sql`${table.locationName} IS NULL`),

View File

@ -113,10 +113,7 @@ export const auditPages = sqliteTable(
// Performance // Performance
responseTimeMs: integer("response_time_ms"), responseTimeMs: integer("response_time_ms"),
}, },
(table) => [ (table) => [index("audit_pages_audit_url_idx").on(table.auditId, table.url)],
index("audit_pages_audit_id_idx").on(table.auditId),
index("audit_pages_audit_url_idx").on(table.auditId, table.url),
],
); );
// One row per unique (source page, target URL) link edge. Currently only // One row per unique (source page, target URL) link edge. Currently only
@ -143,7 +140,6 @@ export const auditLinks = sqliteTable(
.default(false), .default(false),
}, },
(table) => [ (table) => [
index("audit_links_audit_id_idx").on(table.auditId),
index("audit_links_audit_target_idx").on(table.auditId, table.targetUrl), index("audit_links_audit_target_idx").on(table.auditId, table.targetUrl),
], ],
); );
@ -168,7 +164,6 @@ export const auditIssues = sqliteTable(
detailsJson: text("details_json"), detailsJson: text("details_json"),
}, },
(table) => [ (table) => [
index("audit_issues_audit_id_idx").on(table.auditId),
index("audit_issues_audit_type_idx").on(table.auditId, table.issueType), index("audit_issues_audit_type_idx").on(table.auditId, table.issueType),
], ],
); );

View File

@ -236,6 +236,11 @@ export const rankTrackingConfigs = pgTable(
createdAt: timestampColumn("created_at").notNull().default(isoNow), createdAt: timestampColumn("created_at").notNull().default(isoNow),
}, },
(table) => [ (table) => [
index("rank_tracking_configs_project_active_created_idx").on(
table.projectId,
table.isActive,
table.createdAt,
),
uniqueIndex("rank_tracking_configs_national_idx") uniqueIndex("rank_tracking_configs_national_idx")
.on(table.projectId, table.domain, table.locationCode) .on(table.projectId, table.domain, table.locationCode)
.where(sql`${table.locationName} IS NULL`), .where(sql`${table.locationName} IS NULL`),

View File

@ -112,10 +112,7 @@ export const auditPages = pgTable(
// Performance // Performance
responseTimeMs: integer("response_time_ms"), responseTimeMs: integer("response_time_ms"),
}, },
(table) => [ (table) => [index("audit_pages_audit_url_idx").on(table.auditId, table.url)],
index("audit_pages_audit_id_idx").on(table.auditId),
index("audit_pages_audit_url_idx").on(table.auditId, table.url),
],
); );
// One row per unique (source page, target URL) link edge. Currently only // One row per unique (source page, target URL) link edge. Currently only
@ -138,7 +135,6 @@ export const auditLinks = pgTable(
isNofollow: boolean("is_nofollow").notNull().default(false), isNofollow: boolean("is_nofollow").notNull().default(false),
}, },
(table) => [ (table) => [
index("audit_links_audit_id_idx").on(table.auditId),
index("audit_links_audit_target_idx").on(table.auditId, table.targetUrl), index("audit_links_audit_target_idx").on(table.auditId, table.targetUrl),
], ],
); );
@ -163,7 +159,6 @@ export const auditIssues = pgTable(
detailsJson: text("details_json"), detailsJson: text("details_json"),
}, },
(table) => [ (table) => [
index("audit_issues_audit_id_idx").on(table.auditId),
index("audit_issues_audit_type_idx").on(table.auditId, table.issueType), index("audit_issues_audit_type_idx").on(table.auditId, table.issueType),
], ],
); );