chore(db): adiciona índice composto para filtros de lançamentos

This commit is contained in:
Felipe Coutinho
2026-03-17 17:07:48 +00:00
parent 36687debf2
commit ff016113b9
4 changed files with 2595 additions and 138 deletions

View File

@@ -0,0 +1 @@
CREATE INDEX "lancamentos_user_id_pagador_id_period_idx" ON "lancamentos" USING btree ("user_id","pagador_id","periodo");

File diff suppressed because it is too large Load Diff

View File

@@ -134,6 +134,13 @@
"when": 1773020417482, "when": 1773020417482,
"tag": "0018_rainy_epoch", "tag": "0018_rainy_epoch",
"breakpoints": true "breakpoints": true
},
{
"idx": 19,
"version": "7",
"when": 1773699152928,
"tag": "0019_ordinary_wild_pack",
"breakpoints": true
} }
] ]
} }

View File

@@ -634,6 +634,12 @@ export const transactions = pgTable(
table.payerId, table.payerId,
table.period, table.period,
), ),
// Índice composto para o filtro quente do dashboard: userId + payerId + period
userIdPayerIdPeriodIdx: index("lancamentos_user_id_pagador_id_period_idx").on(
table.userId,
table.payerId,
table.period,
),
// Índice para queries ordenadas por data de compra // Índice para queries ordenadas por data de compra
userIdPurchaseDateIdx: index("lancamentos_user_id_purchase_date_idx").on( userIdPurchaseDateIdx: index("lancamentos_user_id_purchase_date_idx").on(
table.userId, table.userId,