agrs-sequelize-sdk 1.4.42 → 1.4.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -285,28 +285,36 @@ module.exports = (sequelize, DataTypes) => {
285
285
  { fields: ["vertical", "feed_provider"] },
286
286
  { fields: ["details"], using: "gin" },
287
287
  { fields: ["platform_code"] },
288
- // Expression index on details->>'ai_stage' for Tarzo-only rows.
289
- // Powers the hourly reconciler steps 2/5 (awaiting → COMPLETED) and
290
- // 3/5 (stale → FAILED) added by tarzoMaterializationReconciler.
291
- // Without this the queries do a full-table scan of the 50GB+ table
292
- // and time out (verified in prod 2026-07-19: errors=3 every hour).
293
- // Partial WHERE keeps the index tiny only Tarzo awaiting/failed
294
- // rows are indexed, not the whole table.
288
+ // Partial indexes for the hourly Tarzo reconciler (steps 2/5 and 3/5
289
+ // in reconcilerService.js). Both steps filter on:
290
+ // status='IN_PROGRESS'
291
+ // AND details->>'ai_stage'='tarzo_awaiting_materialization'
292
+ // Predicate is equality NOT `LIKE 'tarzo_%'` because Postgres's
293
+ // partial-index prover doesn't cross equality→LIKE, so a LIKE-predicate
294
+ // index would be ignored (verified in prod 2026-07-19). Equality
295
+ // matches the queries verbatim, so the planner picks these up.
296
+ //
297
+ // Column choices:
298
+ // - feed_campaign_id: drives the nested-loop join to
299
+ // rsoc_feed_campaigns.AGRS_CID in step 2/5.
300
+ // - created_at: powers the stale age filter in step 3/5.
301
+ //
302
+ // Self-pruning: rows leave the index as soon as status flips to
303
+ // COMPLETED/FAILED, so index size stays proportional to in-flight
304
+ // rows only.
295
305
  {
296
- name: "idx_v2_ai_stage_tarzo",
297
- fields: [sequelize.literal(`((details->>'ai_stage'))`)],
298
- where: sequelize.literal(`(details->>'ai_stage') LIKE 'tarzo_%'`),
306
+ name: "idx_v2_awaiting_by_feed_campaign",
307
+ fields: ["feed_campaign_id"],
308
+ where: sequelize.literal(
309
+ `status = 'IN_PROGRESS' AND (details->>'ai_stage') = 'tarzo_awaiting_materialization'`
310
+ ),
299
311
  },
300
- // Composite index for the stale-cleanup query (step 3/5) which
301
- // filters by ai_stage AND created_at < now() - 6h. Same partial
302
- // WHERE keeps size minimal.
303
312
  {
304
- name: "idx_v2_ai_stage_tarzo_created_at",
305
- fields: [
306
- sequelize.literal(`((details->>'ai_stage'))`),
307
- { name: "created_at", order: "DESC" },
308
- ],
309
- where: sequelize.literal(`(details->>'ai_stage') LIKE 'tarzo_%'`),
313
+ name: "idx_v2_awaiting_created_at",
314
+ fields: [{ name: "created_at", order: "DESC" }],
315
+ where: sequelize.literal(
316
+ `status = 'IN_PROGRESS' AND (details->>'ai_stage') = 'tarzo_awaiting_materialization'`
317
+ ),
310
318
  },
311
319
  ],
312
320
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agrs-sequelize-sdk",
3
- "version": "1.4.42",
3
+ "version": "1.4.43",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "start": "node index.js",