Files
accounted/supabase/migrations/20260807151000_journal_entry_lines_account_id_index.sql
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

12 lines
683 B
SQL

-- journal_entry_lines.account_id (FK to chart_of_accounts, ON DELETE SET
-- NULL) has no index, while account_number, journal_entry_id, cost_center,
-- project and the dimension bags all do. Deleting a chart account therefore
-- seq-scans all ~730k journal_entry_lines rows per account; sandbox teardown
-- deletes ~37 chart accounts per company, which is where most of its ~3s
-- per-user cost goes (caught live: the backlog purge timed out inside
-- "UPDATE ONLY journal_entry_lines SET account_id = NULL WHERE account_id =
-- $1" cascading from DELETE FROM auth.users).
CREATE INDEX IF NOT EXISTS idx_journal_entry_lines_account_id
ON public.journal_entry_lines (account_id);