Waiting for data...
Monitoring 6 aggregate metrics from a single SQL subscription -- every INSERT, UPDATE, or DELETE recomputes all KPIs atomically.
This single-row aggregate query demonstrates pg_reactive's ability to track computed
metrics like COUNT(DISTINCT), SUM/AVG ratios, and NULLIF-guarded divisions.
Unlike CDC tools which only emit row-level changes, pg_reactive recomputes the full aggregate
and delivers the exact delta.
-- Connect to the database
-- docker compose exec -T db psql -U postgres -d pg_reactive_test
-- Place a new order (increases total_orders, total_revenue, avg_order_value)
INSERT INTO orders (customer_id, product_id, qty, total)
VALUES (1, 2, 3, 449.97);
-- Add a new customer (increases active_customers, changes revenue_per_customer)
INSERT INTO customers (name, region)
VALUES ('Eve', 'eu-west');
-- Add a new product (increases products_sold)
INSERT INTO products (name, price, category)
VALUES ('Ergonomic Keyboard', 189.99, 'electronics');
-- Delete an order (decreases totals)
DELETE FROM orders
WHERE customer_id = 2 LIMIT 1;