import { BaseSchema } from '@adonisjs/lucid/schema' /** * The discard sweep of a dropped signature (tool, group, poster) read the whole pending_releases table per * signature: the planner took a parallel seq scan over the poster test, four minutes on the HDD that starved the * lanes' claims (LOG.md (134)). The waiting rows by signature make it an index range. By the poster's md5: a * poster of 2.7 kB broke the first build (a btree key is at most a third of a page), which left an invalid index * behind that IF NOT EXISTS would have taken for the real one; the drop clears it. */ export default class extends BaseSchema { static disableTransactions = true async up() { this.schema.raw(`DROP INDEX CONCURRENTLY IF EXISTS pending_releases_signature_idx`) this.schema.raw( `CREATE INDEX CONCURRENTLY IF NOT EXISTS pending_releases_signature_idx ON pending_releases (group_id, tool, md5(poster)) WHERE status = 0` ) } async down() { this.schema.raw(`DROP INDEX CONCURRENTLY IF EXISTS pending_releases_signature_idx`) } }