PostgreSQL Database Architecture & Automated Cron Pipelines¶
Document Control:
* Publisher: Flavius Narokobi
* Target Audience: Database Administrators, Backend Engineers, Infrastructure Leads
* Applicable Environments: Staging & Production
* Standard Version: v2.7.0
* Effective Date: October 2026
* Document Status: Production Certified
1. PostgreSQL 15 Engine Configuration¶
Both Production (cpl_real_rewards) and Staging (cpl_real_rewards_staging) run on PostgreSQL 15 tuned for high-concurrency loyalty transactions:
shared_buffers = 2GB
work_mem = 64MB
maintenance_work_mem = 512MB
effective_cache_size = 6GB
random_page_cost = 1.1
checkpoint_completion_target = 0.9
wal_buffers = 16MB
max_connections = 100
2. High-Performance B-Tree Index Architecture¶
To support instantaneous multi-token searches and high-volume POS ledger lookups, the following production indexes are maintained:
graph TD
Query["Incoming POS Query / Search"] --> PartnerIdx["res_partner Indexes"]
Query --> LedgerIdx["loyalty_ledger Indexes"]
Query --> QuarantineIdx["quarantine_queue Indexes"]
PartnerIdx --> P1["rrp_card_number (B-tree)"]
PartnerIdx --> P2["primary_store_id (B-tree)"]
PartnerIdx --> P3["is_card_blocked (B-tree)"]
LedgerIdx --> L1["partner_id (B-tree)"]
LedgerIdx --> L2["order_reference (B-tree)"]
LedgerIdx --> L3["transaction_date (B-tree)"]
LedgerIdx --> L4["shop_id (B-tree)"]
QuarantineIdx --> Q1["card_number (B-tree)"]
QuarantineIdx --> Q2["order_id (B-tree)"]
QuarantineIdx --> Q3["state (B-tree)"]
Critical Database Index Commands:¶
-- Ensure instant card resolution
CREATE INDEX IF NOT EXISTS res_partner__rrp_card_number_idx ON res_partner(rrp_card_number);
CREATE INDEX IF NOT EXISTS res_partner__primary_store_id_idx ON res_partner(primary_store_id);
CREATE INDEX IF NOT EXISTS res_partner__is_card_blocked_idx ON res_partner(is_card_blocked);
-- Ledger and quarantine lookup acceleration
CREATE INDEX IF NOT EXISTS real_rewards_loyalty_ledger__partner_id_idx ON real_rewards_loyalty_ledger(partner_id);
CREATE INDEX IF NOT EXISTS real_rewards_loyalty_ledger__order_ref_idx ON real_rewards_loyalty_ledger(order_reference);
CREATE INDEX IF NOT EXISTS real_rewards_quarantine_queue__card_num_idx ON real_rewards_quarantine_queue(card_number);
CREATE INDEX IF NOT EXISTS real_rewards_quarantine_queue__state_idx ON real_rewards_quarantine_queue(state);
⏰ 3. Automated Cron Pipelines (ir.cron)¶
Odoo executes background automated scheduled actions to maintain financial consistency and system hygiene:
| Cron Job XML ID | Job Name | Frequency | Target Model / Function | Operational Objective |
|---|---|---|---|---|
cron_daily_points_accounting |
Daily Points Accounting Sync | Daily at 23:59 | real.rewards.daily.points.accounting $\rightarrow$ action_recompute_all() |
Aggregates daily points earned, redeemed, and liabilities per retail store. |
cron_autovacuum_transients |
Transient Wizard Cleanup | Daily at 02:00 | ir.attachment / wizard tables |
Cleans completed claim modals and temporary export files. |
cron_pos_order_dedup_check |
POS Transaction Dedup Verification | Hourly | real_rewards_importer $\rightarrow$ _check_deduplication() |
Confirms zero duplicate POS receipt references across ledgers. |