From 1af98b690ba7cccb14c524df83c5bb297896a38f Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sat, 3 May 2025 12:57:50 +0900 Subject: feat: CREATE INDEX CONCURRENTLY for "userId" "id" composite note index if admin wish. (#15915) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: CREATE INDEX CONCURRENTLY for "userId" "id" composite note index * chore: remove { concurrent: true } and comment why * update comment * feat: add MISSKEY_MIGRATION_CREATE_INDEX_CONCURRENTLY option * fix: spdx license header * alter comment * chore: improve behavior when migration failure * docs(changelog): 2025.4.1 で追加されたインデックスの再生成をノートの追加しながら行えるようになりました * ちょっと表現を変更 --------- Co-authored-by: 饺子w (Yumechi) <35571479+eternal-flame-ad@users.noreply.github.com> --- packages/backend/src/models/Note.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'packages/backend/src/models/Note.ts') diff --git a/packages/backend/src/models/Note.ts b/packages/backend/src/models/Note.ts index abaf615bcf..3dcbdb735b 100644 --- a/packages/backend/src/models/Note.ts +++ b/packages/backend/src/models/Note.ts @@ -10,6 +10,16 @@ import { MiUser } from './User.js'; import { MiChannel } from './Channel.js'; import type { MiDriveFile } from './DriveFile.js'; +// Note: When you create a new index for existing column of this table, +// it might be better to index concurrently under isConcurrentIndexMigrationEnabled flag +// by editing generated migration file since this table is very large, +// and it will make a long lock to create index in most cases. +// Please note that `CREATE INDEX CONCURRENTLY` is not supported in transaction, +// so you need to set `transaction = false` in migration if isConcurrentIndexMigrationEnabled() is true. +// Please refer 1745378064470-composite-note-index.js for example. +// You should not use `@Index({ concurrent: true })` decorator because database initialization for test will fail +// because it will always run CREATE INDEX in transaction based on decorators. +// Not appending `{ concurrent: true }` to `@Index` will not cause any problem in production, @Index(['userId', 'id']) @Entity('note') export class MiNote { -- cgit v1.2.3-freya