At a glance
PostgreSQL Inventory Rows vs Ecom Inventory Count reconciles the stock figures held in your PostgreSQL inventory table against the stock count the storefront is publishing through the ecommerce connector. It is a drift detector: when the database (your system of record) and the storefront (what shoppers see) disagree on how many units of a SKU are available, you are either overselling stock you do not have or hiding stock you could be selling. Both cost money. The card surfaces the SKUs where the two counts have diverged, so a platform team can catch a broken sync job before it turns into cancelled orders or dead inventory.
Calculation
The engine takes the per-SKU available quantity from the PostgreSQL inventory table (the system of record) and joins it, by SKU, to the published inventory level returned by the storefront connector’s inventory API. For each SKU it computes the difference:Worked example
A platform team runs the storefront on Shopify and keeps inventory authoritative in PostgreSQL, pushing updates to Shopify through a sync worker every five minutes. On 18 Apr 26 at 14:20 BST the card flags drift. The detail table:
The card headline reads 4 SKUs drifting and the
> 0 alert has tripped. The team reads the rows by risk:
- Two SKUs are overselling, which is the dangerous direction. The oak table reads zero in the database but the storefront still advertises 14 units. Every order placed against those phantom 14 will be accepted and then cancelled, producing refunds, chargebacks, and one-star reviews. The linen chair is worse in volume: the storefront is offering 42 units that do not exist.
- One SKU is underselling, which is lost revenue rather than a customer-trust hit. The brass lamp has 120 units in the database but shows zero on the storefront, so it is invisible to shoppers. No orders, no complaints, just silent missed sales.
- One SKU is in-flight. The wool rug differs by two units, consistent with an order placed seconds before the sync cycle. The 24-hour view shows it self-correcting on the next sync; it is not a fault.
- Direction decides urgency. Overselling (storefront higher than database) damages customers and trust and must be fixed first. Underselling (database higher than storefront) is lost revenue you can recover once the sync is healthy. Always read the sign of the drift, not just the count.
- Small drift on hot SKUs is normal; persistent drift is a broken sync. A SKU off by one or two units for one sync cycle is in-flight inventory. The same SKU drifting for an hour, or the drift count climbing across the 24-hour view, means the pipeline has stalled.
- The database is the truth, the storefront is the symptom. When the two disagree, fix the propagation from PostgreSQL to the storefront rather than editing the storefront directly, which only masks the underlying sync fault and creates a second source of truth.
Sibling cards
Reconciling against the source
Where to look directly:
On the PostgreSQL side, query the inventory table for the authoritative per-SKU quantity, for example SELECT sku, available_qty FROM inventory WHERE sku = ANY($1); for the drifting SKUs the card lists.
On the ecom side, read the same SKUs back from the storefront’s inventory API: Shopify’s InventoryLevel / GraphQL inventory query, BigCommerce’s catalogue inventory endpoint, or Adobe Commerce’s stock items API.
Compare the two numbers per SKU. The difference is the drift the card reports.
Why our number may legitimately differ from a manual check:
On managed platforms: the storefront side is reconciled in the merchant admin (Shopify admin Inventory, BigCommerce Products inventory, Adobe Commerce catalogue stock), and the PostgreSQL side against the live table on the primary. There is no managed-service console number for this card; the reconciliation is always database row versus storefront API.