diff --git a/database/migrate/migrate_test.go b/database/migrate/migrate_test.go index 93c86e36fc..31dc69e9ce 100644 --- a/database/migrate/migrate_test.go +++ b/database/migrate/migrate_test.go @@ -63,7 +63,7 @@ func testResetDB(t *testing.T) { cur, err := Current(pgDB.DB) assert.NoError(t, err) // total number of tables. - assert.Equal(t, 9, int(cur)) + assert.Equal(t, 10, int(cur)) } func testMigrate(t *testing.T) { diff --git a/database/migrate/migrations/00010_add_index_chunk_prover_task.sql b/database/migrate/migrations/00010_add_index_chunk_prover_task.sql new file mode 100644 index 0000000000..73c47329a1 --- /dev/null +++ b/database/migrate/migrations/00010_add_index_chunk_prover_task.sql @@ -0,0 +1,19 @@ +-- +goose Up +-- +goose StatementBegin + +create index if not exists idx_chunk_hash on chunk(hash, deleted_at) where deleted_at IS NULL; + +create index if not exists idx_proving_status_end_block_number_index on chunk(index, end_block_number, proving_status, deleted_at) where deleted_at IS NULL; + +create index if not exists idx_publickey_proving_status on prover_task(prover_public_key, proving_status, deleted_at, id) where deleted_at is null; + +-- +goose StatementEnd + +-- +goose Down +-- +goose StatementBegin + +drop index if exists idx_chunk_hash; +drop index if exists idx_proving_status_end_block_number_index; +drop index if exists idx_publickey_proving_status; + +-- +goose StatementEnd