Å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.
21 lines
948 B
SQL
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';
|