Skip to content

Commit 6f43b3e

Browse files
authored
Remove redundant indices (#6791)
1 parent 6c0b6f3 commit 6f43b3e

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

.changeset/nine-timers-complain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'hive': patch
3+
---
4+
5+
Remove redundant pg indices
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { type MigrationExecutor } from '../pg-migrator';
2+
3+
/**
4+
* This migration removes indices that are covered by other btree indices.
5+
* This should have no impact on performance while lowering our db footprint.
6+
*/
7+
export default {
8+
name: '2025.05.15T00-00-00.redundant-indices.ts',
9+
noTransaction: true,
10+
run: ({ sql }) => [
11+
// redundant with schema_versions_cursor_pagination
12+
{
13+
name: 'drop index schema_versions_target_id',
14+
query: sql`
15+
DROP INDEX CONCURRENTLY IF EXISTS "schema_versions_target_id"
16+
`,
17+
},
18+
// redundant with organization_member_pkey
19+
{
20+
name: 'drop index organization_member_organization_id',
21+
query: sql`
22+
DROP INDEX CONCURRENTLY IF EXISTS "organization_member_organization_id"
23+
`,
24+
},
25+
// redundant with schema_checks_connection_pagination
26+
{
27+
name: 'drop index schema_checks_target_id',
28+
query: sql`
29+
DROP INDEX CONCURRENTLY IF EXISTS "schema_checks_target_id"
30+
`,
31+
},
32+
// redundant with schema_version_to_log_pkey
33+
{
34+
name: 'drop index schema_version_to_log_version_id',
35+
query: sql`
36+
DROP INDEX CONCURRENTLY IF EXISTS "schema_version_to_log_version_id"
37+
`,
38+
},
39+
],
40+
} satisfies MigrationExecutor;

packages/migrations/src/run-pg-migrations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,6 @@ export const runPGMigrations = async (args: { slonik: DatabasePool; runTo?: stri
163163
await import('./actions/2025.02.21T00-00-00.schema-versions-metadata-attributes'),
164164
await import('./actions/2025.03.20T00-00-00.dangerous_breaking'),
165165
await import('./actions/2025.05.14T00-00-00.cascade-deletion-indices-2'),
166+
await import('./actions/2025.05.15T00-00-00.redundant-indices'),
166167
],
167168
});

0 commit comments

Comments
 (0)