release_chunks' indexes with its chunks (CHUNK_TABLESPACE)
The October partition's three indexes took 2.9 GB of the NVMe, its pkey never scanned; chunks are read from the HDD anyway. Moved on homelab by hand (12 s); the migration does the same on a new deploy, parent indexes too so new partitions follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
256fb24c46
commit
377decaf3d
1 file changed
+26
@@ -0,0 +1,26 @@
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema'
|
||||
import env from '#start/env'
|
||||
|
||||
/**
|
||||
* release_chunks' indexes with its chunks in CHUNK_TABLESPACE (the HDD), not the catalog's tablespace: a chunk is
|
||||
* read from the HDD anyway, and the October partition's three indexes took 2.9 GB of the NVMe (its pkey never
|
||||
* scanned; LOG.md 2026-10-14 (54)). The parent's partitioned indexes too, so new partitions put theirs there.
|
||||
* Homelab was moved by hand first; a no-op where they're there already.
|
||||
*/
|
||||
export default class extends BaseSchema {
|
||||
async up() {
|
||||
const tablespace = env.get('CHUNK_TABLESPACE')
|
||||
if (!tablespace) return
|
||||
this.defer(async (db) => {
|
||||
const { rows } = await db.rawQuery(
|
||||
`SELECT i.relname FROM pg_class c JOIN pg_index x ON x.indrelid = c.oid JOIN pg_class i ON i.oid = x.indexrelid
|
||||
LEFT JOIN pg_tablespace t ON t.oid = i.reltablespace
|
||||
WHERE c.relname LIKE 'release_chunks%' AND coalesce(t.spcname, 'pg_default') <> ?`,
|
||||
[tablespace]
|
||||
)
|
||||
for (const { relname } of rows) await db.rawQuery(`ALTER INDEX ${relname} SET TABLESPACE ${tablespace}`)
|
||||
})
|
||||
}
|
||||
|
||||
async down() {}
|
||||
}
|
||||
Reference in new issue
Block a user