-- Performance: journal_entry_lines had no FK indexes, so every nested
-- journal_entries -> journal_entry_lines fetch seq-scanned all lines per entry.
-- For Bridgewater (4,189 JEs / 10,075 lines) the JE + GL pages exceeded the 8s
-- statement timeout and rendered empty.
create index if not exists journal_entry_lines_journal_entry_id_idx
  on accounting.journal_entry_lines (journal_entry_id);

create index if not exists journal_entry_lines_account_id_idx
  on accounting.journal_entry_lines (account_id);

create index if not exists journal_entries_company_date_idx
  on accounting.journal_entries (company_id, date);
