Real-Time CRM Dashboard

Top Customers
Recent Orders
By Region
pg_reactive Example 5 — CTE + LIMIT + Multi-Query

Top Customers

CTE + JOIN
  • Connecting...

Recent Orders

LIMIT 10
ID Customer Product Total Time
Connecting...

Revenue by Region

GROUP BY
Region Customers Orders Revenue
Connecting...
A single INSERT INTO orders triggers delta computation for all three panels simultaneously. The CTE in Query 1, the LIMIT in Query 2, and the GROUP BY in Query 3 all update correctly. No other push-based approach can handle even one of these query types — let alone all three running concurrently.
-- One INSERT updates ALL THREE panels
INSERT INTO orders (customer_id, product_id, qty, total) VALUES (1, 3, 1, 349.99);

-- Multiple orders change rankings
INSERT INTO orders (customer_id, product_id, qty, total) VALUES (2, 1, 3, 239.97);
INSERT INTO orders (customer_id, product_id, qty, total) VALUES (3, 7, 5, 349.95);
INSERT INTO orders (customer_id, product_id, qty, total) VALUES (4, 3, 2, 699.98);

-- New customer + order
INSERT INTO customers (name, region) VALUES ('Eve Garcia', 'eu-west');
INSERT INTO orders (customer_id, product_id, qty, total) VALUES (5, 3, 1, 349.99);