Files
accounted/supabase/migrations/20260617120000_worklist_indexes.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

21 lines
948 B
SQL

-- Worklist (Att göra) badge counts run on every dashboard render via the
-- layout, so the two hottest predicates get purpose-built indexes:
--
-- 1. Unbooked bank transactions (lib/worklist countUnbookedTransactions):
-- company_id WHERE is_business IS NULL AND is_ignored = false. The
-- existing idx_transactions_company_id scans every row of the company;
-- this partial index holds only the (small, shrinking) inbox set.
--
-- 2. invoice_inbox_items is only indexed by user_id (from before the
-- multi-tenant refactor), but every core read — inbox-available, the
-- worklist count — filters by company_id.
CREATE INDEX IF NOT EXISTS idx_transactions_company_unbooked
ON public.transactions (company_id)
WHERE is_business IS NULL AND is_ignored = false;
CREATE INDEX IF NOT EXISTS idx_invoice_inbox_items_company_created
ON public.invoice_inbox_items (company_id, created_at DESC);
NOTIFY pgrst, 'reload schema';