Finding the bottleneck in a simulated last-mile sorting station

Lab notes

Diagram of a simulated parcel sorting line

Status: build in progress. This note describes the question, the data model, the queries and the dashboard design. Results will be added from my own run.

Lab note 01 from a one-person practice lab in Aachen. The sorting station below is invented and deliberately simple. It describes no real company, site, or process, and every row of data will come from a small simulation I write and run myself.

The question

The last step before a parcel goes out for delivery is often a sorting station that works through the night. Parcels arrive in an overnight inbound wave and pass through four steps: they are inducted, sorted to their delivery route, bagged per route, and staged for morning dispatch. Whatever is not staged by the dispatch cut-off misses its departure.

A chain moves only as fast as its slowest link, so one plain question matters more than any other: which step limits the station, and can I tell from the event records alone? A second sits next to it: what share of parcels is staged before the cut-off, and how is that share tied to the limiting step?

I want to answer both from the records the station leaves behind, not by watching it. That needs three pieces: a data set, a model to hold it, and a dashboard that answers the questions for someone who will never read the SQL.

The data, and the answers I plant

I have no operational data, and a public lab note should not use any. So the data comes from a discrete-event simulation in Python with SimPy. Four single-operator steps, Induct, Sort to route, Bag, and Stage for dispatch, are linked by buffers. When a buffer is full, the step before it holds its finished parcel and is blocked. When a buffer is empty, the step after it waits and is starved. A small share of parcels is rejected at Sort to route, for example for an unreadable label. Every parcel carries a route from the moment it arrives, and Bag places it in the bag of that route; closing and replacing bags is not modelled.

Steps break down at random, but only between parcels: a breakdown never interrupts a service and never starts while a step is blocked. Running, blocked, and down time therefore cannot overlap, which matters because starved time is computed as what is left over.

The design parameters, which are inputs and not results:

  • One overnight sort shift of 8 h; breaks and travel time not modelled; 20 shifts per scenario.

  • The inbound wave fills the first 7 h of the shift, and no parcels arrive in the last hour.

  • Dispatch cut-off 30 min before the planned end of the shift, that is, 27,000 s after the shift starts.

  • 20 delivery routes; each parcel is assigned one at random, with equal probability.

  • Buffer size 5 places between two steps; the queue in front of Induct is unbounded.

  • Mean time between breakdowns 3,600 s and mean repair time 240 s at every step, unless a scenario says otherwise.

  • Reject probability at Sort to route 1%.

  • Ideal cycle in seconds (Induct, Sort to route, Bag, Stage for dispatch): 3.0, 3.2, 4.0, 3.0 in scenarios A and C, and 3.0, 4.6, 4.0, 3.0 in scenario B, plus a random extra with a mean of 0.8 s.

  • Mean time between arrivals during the wave: 6.0 s off-peak; at the peak in the middle of the wave, 4.2 s in A and C, and 5.0 s in B. At the peak, parcels arrive faster than the slowest cycle can clear them (4.0 + 0.8 s at Bag in A, and 4.6 + 0.8 s at Sort to route in B), so the station is genuinely loaded for part of every shift.

  • Scenario C only: Sort to route has a mean time between breakdowns of 1,800 s and a mean repair time of 900 s.

These scenarios are the test design. I plant a bottleneck at Bag in A and at Sort to route in B to test whether the queries recover it. In A and B the planted constraint is also the step with the slowest cycle, so a method that merely ranked cycle times would pass both. Scenario C closes that loophole: Bag keeps the slowest cycle, while long repairs are meant to make Sort to route the constraint. If the method points at Bag in A, at Sort to route in B, and at Sort to route again in C, it works on cases where I know the truth. If it does not, I learn that cheaply. Three planted cases are a sanity check, not a proof that the method works in general.

The cut-off is a second outcome, not a second test with a planted answer. I make no prediction about its value; I only plan to read it next to the constraint in each scenario.

The data model

The most important modelling decision is the grain, the one sentence that says what a single row means. I keep four raw facts with different grains on purpose:

  • fact_arrival: one row per parcel that arrives in the inbound wave, with its route. It is the only place where parcels that never start Induct are visible.

  • fact_parcel_step: one row per parcel, per step, per shift, written when the step starts serving the parcel. Counts, rejects, service time, blocked time, and queue time come from here. A step still open at shift end (in service, or finished but blocked) is closed by the simulator at the planned end of the shift and flagged censored, so none of its running or blocked seconds leak into the starved remainder.

  • fact_breakdown: one row per breakdown interval of one step. The simulator clips an interval that crosses the end of the shift, and Q1 clips it again as a guard.

  • fact_shift_end: one row per shift, written from the simulator’s own counters (arrived, completed, rejected, waiting in front of Induct, and inside the station). These counters are kept apart from the event rows, so they can catch rows that went missing on the way into the database.

Putting steps and breakdowns into one table would force a choice between counting parcels and summing seconds, and one of the two would come out wrong. All facts share the station and shift dimensions; in the tables, dim_station holds the four steps. Each step carries a step_order, so no query depends on a step’s name. The ideal cycle differs between scenarios, so it lives in its own table keyed by step and scenario. The cut-off is stored on the shift, so a later scenario can move it without touching any query.

Two derived tables sit on top. station_shift is a periodic snapshot with exactly one row per step per shift. It is built from a grid of every shift and every step, so a step that served nothing in a shift still gets a row of zeros instead of disappearing. Its counts and seconds add up across shifts and steps, with one exception: planned_s and run_s are semi-additive. They add up across the shifts of one step, but summing them over the four steps of a shift gives four times the shift. Every OEE figure in this note is therefore per step.

parcel_journey is an accumulating snapshot with exactly one row per arriving parcel and one column per milestone: arrived, induct started, sorted, bagged, and staged. The periodic snapshot cannot answer the cut-off question, because it has already summed parcels into seconds per step and lost the moment each parcel was staged. The journey table keeps that moment, and a parcel that never reaches a milestone keeps an empty value there.

Times are stored in UTC. Each shift carries its start as a UTC timestamp, and events carry seconds since that start, so all arithmetic is in seconds, an overnight shift that crosses midnight needs no special case, and a daylight-saving change can never stretch or shrink a shift. Tableau cannot convert time zones, so the export adds one display-only column, computed in DuckDB with the ICU extension: shift_start_utc AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Berlin' AS shift_start_local.

CREATE TABLE dim_shift (
  shift_id        INTEGER PRIMARY KEY,
  scenario        VARCHAR NOT NULL CHECK (scenario IN ('A', 'B', 'C')),
  shift_start_utc TIMESTAMP NOT NULL,   -- always UTC
  planned_s       DOUBLE  NOT NULL,
  cutoff_s        DOUBLE  NOT NULL,     -- dispatch cut-off, seconds since start
  CHECK (cutoff_s > 0 AND cutoff_s <= planned_s)
);
CREATE TABLE dim_station (
  station_id   SMALLINT PRIMARY KEY,
  station_name VARCHAR  NOT NULL,
  step_order   SMALLINT NOT NULL UNIQUE
);
INSERT INTO dim_station VALUES
  (1, 'Induct', 1), (2, 'Sort to route', 2),
  (3, 'Bag', 3),    (4, 'Stage for dispatch', 4);
CREATE TABLE dim_station_config (
  station_id    SMALLINT NOT NULL REFERENCES dim_station (station_id),
  scenario      VARCHAR  NOT NULL,
  ideal_cycle_s DOUBLE   NOT NULL,
  PRIMARY KEY (station_id, scenario)
);
-- Grain: one row per arriving parcel.
CREATE TABLE fact_arrival (
  shift_id   INTEGER  NOT NULL REFERENCES dim_shift (shift_id),
  parcel_id  BIGINT   NOT NULL,
  route_id   SMALLINT NOT NULL,
  arrival_s  DOUBLE   NOT NULL,
  PRIMARY KEY (shift_id, parcel_id)
);
-- Grain: one row per parcel, per step, per shift.
CREATE TABLE fact_parcel_step (
  shift_id      INTEGER  NOT NULL,
  parcel_id     BIGINT   NOT NULL,
  station_id    SMALLINT NOT NULL,
  queue_enter_s DOUBLE NOT NULL, start_s DOUBLE NOT NULL,
  end_s         DOUBLE NOT NULL, release_s DOUBLE NOT NULL,
  outcome       VARCHAR  NOT NULL CHECK (outcome IN ('good', 'reject', 'open')),
  censored      BOOLEAN  NOT NULL,   -- closed at the end of the shift
  PRIMARY KEY (shift_id, parcel_id, station_id),
  FOREIGN KEY (shift_id, parcel_id) REFERENCES fact_arrival (shift_id, parcel_id),
  FOREIGN KEY (station_id) REFERENCES dim_station (station_id)
);
-- Grain: one row per breakdown interval of one step.
CREATE TABLE fact_breakdown (
  shift_id     INTEGER  NOT NULL REFERENCES dim_shift (shift_id),
  station_id   SMALLINT NOT NULL REFERENCES dim_station (station_id),
  down_start_s DOUBLE   NOT NULL,
  down_end_s   DOUBLE   NOT NULL,
  PRIMARY KEY (shift_id, station_id, down_start_s),
  CHECK (down_end_s > down_start_s)
);
-- Grain: one row per shift, from the simulator's own counters.
CREATE TABLE fact_shift_end (
  shift_id       INTEGER PRIMARY KEY REFERENCES dim_shift (shift_id),
  arrived_n      BIGINT NOT NULL, completed_n    BIGINT NOT NULL,
  rejected_n     BIGINT NOT NULL, induct_queue_n BIGINT NOT NULL,
  in_line_wip_n  BIGINT NOT NULL
);
CREATE TABLE dim_shift (
  shift_id        INTEGER PRIMARY KEY,
  scenario        VARCHAR NOT NULL CHECK (scenario IN ('A', 'B', 'C')),
  shift_start_utc TIMESTAMP NOT NULL,   -- always UTC
  planned_s       DOUBLE  NOT NULL,
  cutoff_s        DOUBLE  NOT NULL,     -- dispatch cut-off, seconds since start
  CHECK (cutoff_s > 0 AND cutoff_s <= planned_s)
);
CREATE TABLE dim_station (
  station_id   SMALLINT PRIMARY KEY,
  station_name VARCHAR  NOT NULL,
  step_order   SMALLINT NOT NULL UNIQUE
);
INSERT INTO dim_station VALUES
  (1, 'Induct', 1), (2, 'Sort to route', 2),
  (3, 'Bag', 3),    (4, 'Stage for dispatch', 4);
CREATE TABLE dim_station_config (
  station_id    SMALLINT NOT NULL REFERENCES dim_station (station_id),
  scenario      VARCHAR  NOT NULL,
  ideal_cycle_s DOUBLE   NOT NULL,
  PRIMARY KEY (station_id, scenario)
);
-- Grain: one row per arriving parcel.
CREATE TABLE fact_arrival (
  shift_id   INTEGER  NOT NULL REFERENCES dim_shift (shift_id),
  parcel_id  BIGINT   NOT NULL,
  route_id   SMALLINT NOT NULL,
  arrival_s  DOUBLE   NOT NULL,
  PRIMARY KEY (shift_id, parcel_id)
);
-- Grain: one row per parcel, per step, per shift.
CREATE TABLE fact_parcel_step (
  shift_id      INTEGER  NOT NULL,
  parcel_id     BIGINT   NOT NULL,
  station_id    SMALLINT NOT NULL,
  queue_enter_s DOUBLE NOT NULL, start_s DOUBLE NOT NULL,
  end_s         DOUBLE NOT NULL, release_s DOUBLE NOT NULL,
  outcome       VARCHAR  NOT NULL CHECK (outcome IN ('good', 'reject', 'open')),
  censored      BOOLEAN  NOT NULL,   -- closed at the end of the shift
  PRIMARY KEY (shift_id, parcel_id, station_id),
  FOREIGN KEY (shift_id, parcel_id) REFERENCES fact_arrival (shift_id, parcel_id),
  FOREIGN KEY (station_id) REFERENCES dim_station (station_id)
);
-- Grain: one row per breakdown interval of one step.
CREATE TABLE fact_breakdown (
  shift_id     INTEGER  NOT NULL REFERENCES dim_shift (shift_id),
  station_id   SMALLINT NOT NULL REFERENCES dim_station (station_id),
  down_start_s DOUBLE   NOT NULL,
  down_end_s   DOUBLE   NOT NULL,
  PRIMARY KEY (shift_id, station_id, down_start_s),
  CHECK (down_end_s > down_start_s)
);
-- Grain: one row per shift, from the simulator's own counters.
CREATE TABLE fact_shift_end (
  shift_id       INTEGER PRIMARY KEY REFERENCES dim_shift (shift_id),
  arrived_n      BIGINT NOT NULL, completed_n    BIGINT NOT NULL,
  rejected_n     BIGINT NOT NULL, induct_queue_n BIGINT NOT NULL,
  in_line_wip_n  BIGINT NOT NULL
);
CREATE TABLE dim_shift (
  shift_id        INTEGER PRIMARY KEY,
  scenario        VARCHAR NOT NULL CHECK (scenario IN ('A', 'B', 'C')),
  shift_start_utc TIMESTAMP NOT NULL,   -- always UTC
  planned_s       DOUBLE  NOT NULL,
  cutoff_s        DOUBLE  NOT NULL,     -- dispatch cut-off, seconds since start
  CHECK (cutoff_s > 0 AND cutoff_s <= planned_s)
);
CREATE TABLE dim_station (
  station_id   SMALLINT PRIMARY KEY,
  station_name VARCHAR  NOT NULL,
  step_order   SMALLINT NOT NULL UNIQUE
);
INSERT INTO dim_station VALUES
  (1, 'Induct', 1), (2, 'Sort to route', 2),
  (3, 'Bag', 3),    (4, 'Stage for dispatch', 4);
CREATE TABLE dim_station_config (
  station_id    SMALLINT NOT NULL REFERENCES dim_station (station_id),
  scenario      VARCHAR  NOT NULL,
  ideal_cycle_s DOUBLE   NOT NULL,
  PRIMARY KEY (station_id, scenario)
);
-- Grain: one row per arriving parcel.
CREATE TABLE fact_arrival (
  shift_id   INTEGER  NOT NULL REFERENCES dim_shift (shift_id),
  parcel_id  BIGINT   NOT NULL,
  route_id   SMALLINT NOT NULL,
  arrival_s  DOUBLE   NOT NULL,
  PRIMARY KEY (shift_id, parcel_id)
);
-- Grain: one row per parcel, per step, per shift.
CREATE TABLE fact_parcel_step (
  shift_id      INTEGER  NOT NULL,
  parcel_id     BIGINT   NOT NULL,
  station_id    SMALLINT NOT NULL,
  queue_enter_s DOUBLE NOT NULL, start_s DOUBLE NOT NULL,
  end_s         DOUBLE NOT NULL, release_s DOUBLE NOT NULL,
  outcome       VARCHAR  NOT NULL CHECK (outcome IN ('good', 'reject', 'open')),
  censored      BOOLEAN  NOT NULL,   -- closed at the end of the shift
  PRIMARY KEY (shift_id, parcel_id, station_id),
  FOREIGN KEY (shift_id, parcel_id) REFERENCES fact_arrival (shift_id, parcel_id),
  FOREIGN KEY (station_id) REFERENCES dim_station (station_id)
);
-- Grain: one row per breakdown interval of one step.
CREATE TABLE fact_breakdown (
  shift_id     INTEGER  NOT NULL REFERENCES dim_shift (shift_id),
  station_id   SMALLINT NOT NULL REFERENCES dim_station (station_id),
  down_start_s DOUBLE   NOT NULL,
  down_end_s   DOUBLE   NOT NULL,
  PRIMARY KEY (shift_id, station_id, down_start_s),
  CHECK (down_end_s > down_start_s)
);
-- Grain: one row per shift, from the simulator's own counters.
CREATE TABLE fact_shift_end (
  shift_id       INTEGER PRIMARY KEY REFERENCES dim_shift (shift_id),
  arrived_n      BIGINT NOT NULL, completed_n    BIGINT NOT NULL,
  rejected_n     BIGINT NOT NULL, induct_queue_n BIGINT NOT NULL,
  in_line_wip_n  BIGINT NOT NULL
);

The queries

All queries run in DuckDB. Conditional sums use SUM(CASE WHEN … END) rather than FILTER, so they stay portable to other SQL engines.

Q1, step seconds per shift

Running time is end minus start, blocked time is release minus end, and down time comes from the breakdowns. Starved time is what is left of the planned shift. A parcel still in service at shift end adds running seconds but is not counted as a unit, because it has not finished.

CREATE TABLE station_shift AS
WITH grid AS (
  SELECT sh.shift_id, sh.scenario, sh.planned_s, st.station_id
  FROM dim_shift sh CROSS JOIN dim_station st
), steps AS (
  SELECT shift_id, station_id,
         CAST(SUM(CASE WHEN outcome <> 'open' THEN 1 ELSE 0 END) AS BIGINT) AS total_units,
         CAST(SUM(CASE WHEN outcome = 'good'  THEN 1 ELSE 0 END) AS BIGINT) AS good_units,
         SUM(end_s - start_s)   AS running_s,
         SUM(release_s - end_s) AS blocked_s
  FROM fact_parcel_step GROUP BY shift_id, station_id
), downs AS (
  SELECT b.shift_id, b.station_id,
         SUM(LEAST(b.down_end_s, sh.planned_s) - b.down_start_s) AS down_s
  FROM fact_breakdown b JOIN dim_shift sh ON sh.shift_id = b.shift_id
  GROUP BY b.shift_id, b.station_id
)
SELECT g.shift_id, g.station_id, g.scenario, g.planned_s,
       COALESCE(s.total_units, 0) AS total_units,
       COALESCE(s.good_units, 0)  AS good_units,
       COALESCE(s.running_s, 0)   AS running_s,
       COALESCE(s.blocked_s, 0)   AS blocked_s,
       COALESCE(d.down_s, 0)      AS down_s,
       g.planned_s - COALESCE(s.running_s, 0) - COALESCE(s.blocked_s, 0)
                   - COALESCE(d.down_s, 0)  AS starved_s,
       g.planned_s - COALESCE(d.down_s, 0)  AS run_s,
       c.ideal_cycle_s * COALESCE(s.total_units, 0) AS ideal_output_s,
       c.ideal_cycle_s * COALESCE(s.good_units, 0)  AS ideal_good_s
FROM grid g
JOIN dim_station_config c
  ON c.station_id = g.station_id AND c.scenario = g.scenario
LEFT JOIN steps s ON s.shift_id = g.shift_id AND s.station_id = g.station_id
LEFT JOIN downs d ON d.shift_id = g.shift_id AND d.station_id = g.station_id;
CREATE TABLE station_shift AS
WITH grid AS (
  SELECT sh.shift_id, sh.scenario, sh.planned_s, st.station_id
  FROM dim_shift sh CROSS JOIN dim_station st
), steps AS (
  SELECT shift_id, station_id,
         CAST(SUM(CASE WHEN outcome <> 'open' THEN 1 ELSE 0 END) AS BIGINT) AS total_units,
         CAST(SUM(CASE WHEN outcome = 'good'  THEN 1 ELSE 0 END) AS BIGINT) AS good_units,
         SUM(end_s - start_s)   AS running_s,
         SUM(release_s - end_s) AS blocked_s
  FROM fact_parcel_step GROUP BY shift_id, station_id
), downs AS (
  SELECT b.shift_id, b.station_id,
         SUM(LEAST(b.down_end_s, sh.planned_s) - b.down_start_s) AS down_s
  FROM fact_breakdown b JOIN dim_shift sh ON sh.shift_id = b.shift_id
  GROUP BY b.shift_id, b.station_id
)
SELECT g.shift_id, g.station_id, g.scenario, g.planned_s,
       COALESCE(s.total_units, 0) AS total_units,
       COALESCE(s.good_units, 0)  AS good_units,
       COALESCE(s.running_s, 0)   AS running_s,
       COALESCE(s.blocked_s, 0)   AS blocked_s,
       COALESCE(d.down_s, 0)      AS down_s,
       g.planned_s - COALESCE(s.running_s, 0) - COALESCE(s.blocked_s, 0)
                   - COALESCE(d.down_s, 0)  AS starved_s,
       g.planned_s - COALESCE(d.down_s, 0)  AS run_s,
       c.ideal_cycle_s * COALESCE(s.total_units, 0) AS ideal_output_s,
       c.ideal_cycle_s * COALESCE(s.good_units, 0)  AS ideal_good_s
FROM grid g
JOIN dim_station_config c
  ON c.station_id = g.station_id AND c.scenario = g.scenario
LEFT JOIN steps s ON s.shift_id = g.shift_id AND s.station_id = g.station_id
LEFT JOIN downs d ON d.shift_id = g.shift_id AND d.station_id = g.station_id;
CREATE TABLE station_shift AS
WITH grid AS (
  SELECT sh.shift_id, sh.scenario, sh.planned_s, st.station_id
  FROM dim_shift sh CROSS JOIN dim_station st
), steps AS (
  SELECT shift_id, station_id,
         CAST(SUM(CASE WHEN outcome <> 'open' THEN 1 ELSE 0 END) AS BIGINT) AS total_units,
         CAST(SUM(CASE WHEN outcome = 'good'  THEN 1 ELSE 0 END) AS BIGINT) AS good_units,
         SUM(end_s - start_s)   AS running_s,
         SUM(release_s - end_s) AS blocked_s
  FROM fact_parcel_step GROUP BY shift_id, station_id
), downs AS (
  SELECT b.shift_id, b.station_id,
         SUM(LEAST(b.down_end_s, sh.planned_s) - b.down_start_s) AS down_s
  FROM fact_breakdown b JOIN dim_shift sh ON sh.shift_id = b.shift_id
  GROUP BY b.shift_id, b.station_id
)
SELECT g.shift_id, g.station_id, g.scenario, g.planned_s,
       COALESCE(s.total_units, 0) AS total_units,
       COALESCE(s.good_units, 0)  AS good_units,
       COALESCE(s.running_s, 0)   AS running_s,
       COALESCE(s.blocked_s, 0)   AS blocked_s,
       COALESCE(d.down_s, 0)      AS down_s,
       g.planned_s - COALESCE(s.running_s, 0) - COALESCE(s.blocked_s, 0)
                   - COALESCE(d.down_s, 0)  AS starved_s,
       g.planned_s - COALESCE(d.down_s, 0)  AS run_s,
       c.ideal_cycle_s * COALESCE(s.total_units, 0) AS ideal_output_s,
       c.ideal_cycle_s * COALESCE(s.good_units, 0)  AS ideal_good_s
FROM grid g
JOIN dim_station_config c
  ON c.station_id = g.station_id AND c.scenario = g.scenario
LEFT JOIN steps s ON s.shift_id = g.shift_id AND s.station_id = g.station_id
LEFT JOIN downs d ON d.shift_id = g.shift_id AND d.station_id = g.station_id;

Q2, OEE by step and shift

OEE is availability × performance × quality, and figures are only comparable when the convention is stated. Mine: only down time is an availability loss, while starved and blocked time stay in run time and show up as a performance loss. The algebra gives a free check, because OEE then reduces to the ideal time of the good parcels divided by planned time. The view computes OEE both ways, and the two must agree on every row. A step that finished no parcel in a shift has no defined quality, so its product is set to zero, which is also what the direct form gives.

CREATE VIEW oee AS
SELECT shift_id, station_id, scenario,
       run_s / planned_s                         AS availability,
       ideal_output_s / NULLIF(run_s, 0)         AS performance,
       good_units * 1.0 / NULLIF(total_units, 0) AS quality,
       ideal_good_s / planned_s                  AS oee_direct,
       CASE WHEN total_units = 0 OR run_s = 0 THEN 0
            ELSE (run_s / planned_s) * (ideal_output_s / run_s)
                 * (good_units * 1.0 / total_units)
       END                                       AS oee_product
FROM station_shift;

-- Per step and scenario: a ratio of sums, never an average of ratios.
SELECT scenario, station_id,
       SUM(run_s) / SUM(planned_s)          AS availability,
       SUM(ideal_output_s) / SUM(run_s)     AS performance,
       SUM(good_units) * 1.0 / SUM(total_units) AS quality,
       SUM(ideal_good_s) / SUM(planned_s)   AS oee
FROM station_shift
GROUP BY scenario, station_id
ORDER BY scenario, station_id;
CREATE VIEW oee AS
SELECT shift_id, station_id, scenario,
       run_s / planned_s                         AS availability,
       ideal_output_s / NULLIF(run_s, 0)         AS performance,
       good_units * 1.0 / NULLIF(total_units, 0) AS quality,
       ideal_good_s / planned_s                  AS oee_direct,
       CASE WHEN total_units = 0 OR run_s = 0 THEN 0
            ELSE (run_s / planned_s) * (ideal_output_s / run_s)
                 * (good_units * 1.0 / total_units)
       END                                       AS oee_product
FROM station_shift;

-- Per step and scenario: a ratio of sums, never an average of ratios.
SELECT scenario, station_id,
       SUM(run_s) / SUM(planned_s)          AS availability,
       SUM(ideal_output_s) / SUM(run_s)     AS performance,
       SUM(good_units) * 1.0 / SUM(total_units) AS quality,
       SUM(ideal_good_s) / SUM(planned_s)   AS oee
FROM station_shift
GROUP BY scenario, station_id
ORDER BY scenario, station_id;
CREATE VIEW oee AS
SELECT shift_id, station_id, scenario,
       run_s / planned_s                         AS availability,
       ideal_output_s / NULLIF(run_s, 0)         AS performance,
       good_units * 1.0 / NULLIF(total_units, 0) AS quality,
       ideal_good_s / planned_s                  AS oee_direct,
       CASE WHEN total_units = 0 OR run_s = 0 THEN 0
            ELSE (run_s / planned_s) * (ideal_output_s / run_s)
                 * (good_units * 1.0 / total_units)
       END                                       AS oee_product
FROM station_shift;

-- Per step and scenario: a ratio of sums, never an average of ratios.
SELECT scenario, station_id,
       SUM(run_s) / SUM(planned_s)          AS availability,
       SUM(ideal_output_s) / SUM(run_s)     AS performance,
       SUM(good_units) * 1.0 / SUM(total_units) AS quality,
       SUM(ideal_good_s) / SUM(planned_s)   AS oee
FROM station_shift
GROUP BY scenario, station_id
ORDER BY scenario, station_id;

Q3, which step is the constraint?

I rank steps within each shift by active time, the seconds in which a step is working or under repair, and then count how often each step ranks first. Because every step in a shift has the same planned time, ranking by active seconds is the same as ranking by active share. Down time counts as active on purpose: in scenario C, it is what should lift Sort to route above Bag. This is the simple utilisation method; Roser, Nakano, and Tanaka (2001) describe a sharper one based on uninterrupted active periods.

WITH ranked AS (
  SELECT scenario, shift_id, station_id, planned_s,
         running_s + down_s AS active_s,
         RANK() OVER (PARTITION BY shift_id
                      ORDER BY running_s + down_s DESC) AS r
  FROM station_shift
)
SELECT scenario, station_id,
       SUM(CASE WHEN r = 1 THEN 1 ELSE 0 END)   AS shifts_ranked_first,
       COUNT(*)                                 AS shifts,
       ROUND(SUM(active_s) / SUM(planned_s), 3) AS active_share
FROM ranked
GROUP BY scenario, station_id
ORDER BY scenario, shifts_ranked_first DESC;
WITH ranked AS (
  SELECT scenario, shift_id, station_id, planned_s,
         running_s + down_s AS active_s,
         RANK() OVER (PARTITION BY shift_id
                      ORDER BY running_s + down_s DESC) AS r
  FROM station_shift
)
SELECT scenario, station_id,
       SUM(CASE WHEN r = 1 THEN 1 ELSE 0 END)   AS shifts_ranked_first,
       COUNT(*)                                 AS shifts,
       ROUND(SUM(active_s) / SUM(planned_s), 3) AS active_share
FROM ranked
GROUP BY scenario, station_id
ORDER BY scenario, shifts_ranked_first DESC;
WITH ranked AS (
  SELECT scenario, shift_id, station_id, planned_s,
         running_s + down_s AS active_s,
         RANK() OVER (PARTITION BY shift_id
                      ORDER BY running_s + down_s DESC) AS r
  FROM station_shift
)
SELECT scenario, station_id,
       SUM(CASE WHEN r = 1 THEN 1 ELSE 0 END)   AS shifts_ranked_first,
       COUNT(*)                                 AS shifts,
       ROUND(SUM(active_s) / SUM(planned_s), 3) AS active_share
FROM ranked
GROUP BY scenario, station_id
ORDER BY scenario, shifts_ranked_first DESC;

RANK rather than ROW_NUMBER keeps ties visible. One caution I want to keep in view: in this model the constraint may well show the highest OEE, because it is rarely starved or blocked. That is a property of this convention and this station, not a general law. A step with long repairs or many rejects can limit the station and still show a low OEE, and a step with a high OEE can simply be fast. Scenario C is built to test exactly that.

Q4, where do parcels wait?

Queues build in front of a constraint, so this query reports the median and the 90th percentile of waiting time, because a mean hides the long tail. It is measured at Induct, where the only unbounded queue is. Between steps the buffers hold five places, so congestion there shows up as blocked time upstream rather than as a long queue. Parcels still waiting at shift end have no Induct step; instead of dropping them, the query counts their wait up to the end of the shift as a lower bound. Whenever still_waiting is above zero, the p90 is a lower bound too, and the note will say so.

WITH induct AS (
  SELECT station_id FROM dim_station WHERE step_order = 1
), w AS (
  SELECT sh.scenario,
         COALESCE(f.start_s, sh.planned_s) - a.arrival_s AS wait_s,
         f.start_s IS NULL                               AS censored
  FROM fact_arrival a
  JOIN dim_shift sh ON sh.shift_id = a.shift_id
  LEFT JOIN fact_parcel_step f
    ON  f.shift_id = a.shift_id AND f.parcel_id = a.parcel_id
    AND f.station_id = (SELECT station_id FROM induct)
)
SELECT scenario,
       quantile_cont(wait_s, 0.5) AS p50_wait_s,
       quantile_cont(wait_s, 0.9) AS p90_wait_s,
       SUM(CASE WHEN censored THEN 1 ELSE 0 END) AS still_waiting
FROM w
GROUP BY scenario;
WITH induct AS (
  SELECT station_id FROM dim_station WHERE step_order = 1
), w AS (
  SELECT sh.scenario,
         COALESCE(f.start_s, sh.planned_s) - a.arrival_s AS wait_s,
         f.start_s IS NULL                               AS censored
  FROM fact_arrival a
  JOIN dim_shift sh ON sh.shift_id = a.shift_id
  LEFT JOIN fact_parcel_step f
    ON  f.shift_id = a.shift_id AND f.parcel_id = a.parcel_id
    AND f.station_id = (SELECT station_id FROM induct)
)
SELECT scenario,
       quantile_cont(wait_s, 0.5) AS p50_wait_s,
       quantile_cont(wait_s, 0.9) AS p90_wait_s,
       SUM(CASE WHEN censored THEN 1 ELSE 0 END) AS still_waiting
FROM w
GROUP BY scenario;
WITH induct AS (
  SELECT station_id FROM dim_station WHERE step_order = 1
), w AS (
  SELECT sh.scenario,
         COALESCE(f.start_s, sh.planned_s) - a.arrival_s AS wait_s,
         f.start_s IS NULL                               AS censored
  FROM fact_arrival a
  JOIN dim_shift sh ON sh.shift_id = a.shift_id
  LEFT JOIN fact_parcel_step f
    ON  f.shift_id = a.shift_id AND f.parcel_id = a.parcel_id
    AND f.station_id = (SELECT station_id FROM induct)
)
SELECT scenario,
       quantile_cont(wait_s, 0.5) AS p50_wait_s,
       quantile_cont(wait_s, 0.9) AS p90_wait_s,
       SUM(CASE WHEN censored THEN 1 ELSE 0 END) AS still_waiting
FROM w
GROUP BY scenario;

Q5, the parcel journey and the dispatch cut-off

The accumulating snapshot turns the step rows of each parcel into one row with a timestamp per milestone. A milestone counts only when the step finished with a good outcome and was not closed by the end of the shift, so a parcel still in Stage for dispatch at shift end is not staged. A parcel counts as staged before the cut-off when its staged time is at or before cutoff_s.

The share is defined over dispatchable parcels, every arrival that was not rejected, because a rejected parcel was never going to make the morning departure from this station. Parcels staged after the cut-off and parcels not staged at all are reported separately, since they are different failures. Like OEE, the share is a ratio of sums, never an average of per-shift or per-route shares.

-- Accumulating snapshot. Grain: one row per arriving parcel.
CREATE TABLE parcel_journey AS
SELECT a.shift_id, a.parcel_id, a.route_id, sh.scenario, sh.cutoff_s,
       a.arrival_s,
       MAX(CASE WHEN st.step_order = 1 THEN f.start_s END) AS induct_start_s,
       MAX(CASE WHEN st.step_order = 2 AND f.outcome = 'good' AND NOT f.censored
                THEN f.end_s END) AS sorted_s,
       MAX(CASE WHEN st.step_order = 3 AND f.outcome = 'good' AND NOT f.censored
                THEN f.end_s END) AS bagged_s,
       MAX(CASE WHEN st.step_order = 4 AND f.outcome = 'good' AND NOT f.censored
                THEN f.end_s END) AS staged_s,
       COALESCE(MAX(CASE WHEN f.outcome = 'reject' THEN 1 ELSE 0 END), 0) = 1
                                  AS rejected
FROM fact_arrival a
JOIN dim_shift sh ON sh.shift_id = a.shift_id
LEFT JOIN fact_parcel_step f
  ON f.shift_id = a.shift_id AND f.parcel_id = a.parcel_id
LEFT JOIN dim_station st ON st.station_id = f.station_id
GROUP BY a.shift_id, a.parcel_id, a.route_id, sh.scenario, sh.cutoff_s,
         a.arrival_s;

-- Share of dispatchable parcels staged before the cut-off, per scenario.
SELECT scenario,
       SUM(CASE WHEN NOT rejected THEN 1 ELSE 0 END)         AS dispatchable,
       SUM(CASE WHEN staged_s <= cutoff_s THEN 1 ELSE 0 END) AS staged_by_cutoff,
       SUM(CASE WHEN staged_s > cutoff_s THEN 1 ELSE 0 END)  AS staged_late,
       SUM(CASE WHEN staged_s IS NULL AND NOT rejected
                THEN 1 ELSE 0 END)                           AS not_staged,
       SUM(CASE WHEN staged_s <= cutoff_s THEN 1 ELSE 0 END) * 1.0
         / NULLIF(SUM(CASE WHEN NOT rejected THEN 1 ELSE 0 END), 0)
                                                             AS staged_by_cutoff_share
FROM parcel_journey
GROUP BY scenario
ORDER BY scenario;
-- Accumulating snapshot. Grain: one row per arriving parcel.
CREATE TABLE parcel_journey AS
SELECT a.shift_id, a.parcel_id, a.route_id, sh.scenario, sh.cutoff_s,
       a.arrival_s,
       MAX(CASE WHEN st.step_order = 1 THEN f.start_s END) AS induct_start_s,
       MAX(CASE WHEN st.step_order = 2 AND f.outcome = 'good' AND NOT f.censored
                THEN f.end_s END) AS sorted_s,
       MAX(CASE WHEN st.step_order = 3 AND f.outcome = 'good' AND NOT f.censored
                THEN f.end_s END) AS bagged_s,
       MAX(CASE WHEN st.step_order = 4 AND f.outcome = 'good' AND NOT f.censored
                THEN f.end_s END) AS staged_s,
       COALESCE(MAX(CASE WHEN f.outcome = 'reject' THEN 1 ELSE 0 END), 0) = 1
                                  AS rejected
FROM fact_arrival a
JOIN dim_shift sh ON sh.shift_id = a.shift_id
LEFT JOIN fact_parcel_step f
  ON f.shift_id = a.shift_id AND f.parcel_id = a.parcel_id
LEFT JOIN dim_station st ON st.station_id = f.station_id
GROUP BY a.shift_id, a.parcel_id, a.route_id, sh.scenario, sh.cutoff_s,
         a.arrival_s;

-- Share of dispatchable parcels staged before the cut-off, per scenario.
SELECT scenario,
       SUM(CASE WHEN NOT rejected THEN 1 ELSE 0 END)         AS dispatchable,
       SUM(CASE WHEN staged_s <= cutoff_s THEN 1 ELSE 0 END) AS staged_by_cutoff,
       SUM(CASE WHEN staged_s > cutoff_s THEN 1 ELSE 0 END)  AS staged_late,
       SUM(CASE WHEN staged_s IS NULL AND NOT rejected
                THEN 1 ELSE 0 END)                           AS not_staged,
       SUM(CASE WHEN staged_s <= cutoff_s THEN 1 ELSE 0 END) * 1.0
         / NULLIF(SUM(CASE WHEN NOT rejected THEN 1 ELSE 0 END), 0)
                                                             AS staged_by_cutoff_share
FROM parcel_journey
GROUP BY scenario
ORDER BY scenario;
-- Accumulating snapshot. Grain: one row per arriving parcel.
CREATE TABLE parcel_journey AS
SELECT a.shift_id, a.parcel_id, a.route_id, sh.scenario, sh.cutoff_s,
       a.arrival_s,
       MAX(CASE WHEN st.step_order = 1 THEN f.start_s END) AS induct_start_s,
       MAX(CASE WHEN st.step_order = 2 AND f.outcome = 'good' AND NOT f.censored
                THEN f.end_s END) AS sorted_s,
       MAX(CASE WHEN st.step_order = 3 AND f.outcome = 'good' AND NOT f.censored
                THEN f.end_s END) AS bagged_s,
       MAX(CASE WHEN st.step_order = 4 AND f.outcome = 'good' AND NOT f.censored
                THEN f.end_s END) AS staged_s,
       COALESCE(MAX(CASE WHEN f.outcome = 'reject' THEN 1 ELSE 0 END), 0) = 1
                                  AS rejected
FROM fact_arrival a
JOIN dim_shift sh ON sh.shift_id = a.shift_id
LEFT JOIN fact_parcel_step f
  ON f.shift_id = a.shift_id AND f.parcel_id = a.parcel_id
LEFT JOIN dim_station st ON st.station_id = f.station_id
GROUP BY a.shift_id, a.parcel_id, a.route_id, sh.scenario, sh.cutoff_s,
         a.arrival_s;

-- Share of dispatchable parcels staged before the cut-off, per scenario.
SELECT scenario,
       SUM(CASE WHEN NOT rejected THEN 1 ELSE 0 END)         AS dispatchable,
       SUM(CASE WHEN staged_s <= cutoff_s THEN 1 ELSE 0 END) AS staged_by_cutoff,
       SUM(CASE WHEN staged_s > cutoff_s THEN 1 ELSE 0 END)  AS staged_late,
       SUM(CASE WHEN staged_s IS NULL AND NOT rejected
                THEN 1 ELSE 0 END)                           AS not_staged,
       SUM(CASE WHEN staged_s <= cutoff_s THEN 1 ELSE 0 END) * 1.0
         / NULLIF(SUM(CASE WHEN NOT rejected THEN 1 ELSE 0 END), 0)
                                                             AS staged_by_cutoff_share
FROM parcel_journey
GROUP BY scenario
ORDER BY scenario;

The same query grouped by scenario and route_id shows whether misses spread evenly over the routes or gather on a few. With routes assigned at random, I expect no route to stand out by design, so a route that does would point at a fault in the simulator rather than at the station.

Seven data-quality checks

Before I trust any figure, seven checks must each return zero rows:

  1. Grid: every shift has exactly one station_shift row per step.

  2. Bounds: no negative starved time, and no performance above 1.

  3. Identity: no row of the oee view where the product and the direct form differ by more than 1e-9.

  4. Flow order: no step starts before the previous step released the parcel; a parcel with a row at one step has a row at every earlier step; and a rejected parcel has no row after Sort to route.

  5. No overlap: no breakdown overlaps the full interval of a parcel step, from start to release, at the same step.

  6. Conservation: for every shift, the event tables agree with the simulator’s own end-of-shift counters.

  7. Journey: parcel_journey has exactly one row per arrival, its milestones never run backwards (arrived, induct started, sorted, bagged, staged), and its count of parcels staged at any time equals the completed count from the conservation check.

The overlap check uses the half-open interval from start to release, so a step that is blocked while holding a parcel cannot also be under repair:

SELECT f.*
FROM fact_parcel_step f
JOIN fact_breakdown b
  ON  b.shift_id = f.shift_id AND b.station_id = f.station_id
  AND b.down_start_s < f.release_s AND b.down_end_s > f.start_s;
SELECT f.*
FROM fact_parcel_step f
JOIN fact_breakdown b
  ON  b.shift_id = f.shift_id AND b.station_id = f.station_id
  AND b.down_start_s < f.release_s AND b.down_end_s > f.start_s;
SELECT f.*
FROM fact_parcel_step f
JOIN fact_breakdown b
  ON  b.shift_id = f.shift_id AND b.station_id = f.station_id
  AND b.down_start_s < f.release_s AND b.down_end_s > f.start_s;

The conservation check is why fact_arrival and fact_shift_end exist. Each parcel is sorted into exactly one of four groups from the event rows: completed (staged), rejected, still waiting in front of Induct, or inside the station. Those four counts are then compared with the counters the simulator kept by itself. The counters must also balance on their own, and the work inside the station can never exceed the design bound of four steps plus three buffers of five places. A parcel lost between the simulator and the database shows up as a mismatch. What this check proves is that the event tables agree with the simulator; it does not prove that the simulator is right, which is what the planted scenarios are for.

WITH p AS (
  SELECT a.shift_id, a.parcel_id,
         COUNT(f.station_id) AS steps_logged,
         MAX(CASE WHEN f.outcome = 'reject' THEN 1 ELSE 0 END) AS rejected,
         MAX(CASE WHEN st.step_order = (SELECT MAX(step_order) FROM dim_station)
                   AND f.outcome = 'good' AND NOT f.censored
                  THEN 1 ELSE 0 END) AS completed
  FROM fact_arrival a
  LEFT JOIN fact_parcel_step f
    ON f.shift_id = a.shift_id AND f.parcel_id = a.parcel_id
  LEFT JOIN dim_station st ON st.station_id = f.station_id
  GROUP BY a.shift_id, a.parcel_id
), derived AS (
  SELECT shift_id,
         COUNT(*)       AS arrived,
         SUM(completed) AS completed,
         SUM(rejected)  AS rejected,
         SUM(CASE WHEN steps_logged = 0 THEN 1 ELSE 0 END) AS induct_queue,
         SUM(CASE WHEN steps_logged > 0 AND completed = 0
                   AND rejected = 0 THEN 1 ELSE 0 END)     AS in_line_wip
  FROM p GROUP BY shift_id
)
SELECT e.shift_id
FROM fact_shift_end e
LEFT JOIN derived d ON d.shift_id = e.shift_id
WHERE e.arrived_n <> e.completed_n + e.rejected_n
                    + e.induct_queue_n + e.in_line_wip_n
   OR e.in_line_wip_n > 4 + 3 * 5
   OR d.shift_id IS NULL
   OR d.arrived      <> e.arrived_n
   OR d.completed    <> e.completed_n
   OR d.rejected     <> e.rejected_n
   OR d.induct_queue <> e.induct_queue_n
   OR d.in_line_wip  <> e.in_line_wip_n;
WITH p AS (
  SELECT a.shift_id, a.parcel_id,
         COUNT(f.station_id) AS steps_logged,
         MAX(CASE WHEN f.outcome = 'reject' THEN 1 ELSE 0 END) AS rejected,
         MAX(CASE WHEN st.step_order = (SELECT MAX(step_order) FROM dim_station)
                   AND f.outcome = 'good' AND NOT f.censored
                  THEN 1 ELSE 0 END) AS completed
  FROM fact_arrival a
  LEFT JOIN fact_parcel_step f
    ON f.shift_id = a.shift_id AND f.parcel_id = a.parcel_id
  LEFT JOIN dim_station st ON st.station_id = f.station_id
  GROUP BY a.shift_id, a.parcel_id
), derived AS (
  SELECT shift_id,
         COUNT(*)       AS arrived,
         SUM(completed) AS completed,
         SUM(rejected)  AS rejected,
         SUM(CASE WHEN steps_logged = 0 THEN 1 ELSE 0 END) AS induct_queue,
         SUM(CASE WHEN steps_logged > 0 AND completed = 0
                   AND rejected = 0 THEN 1 ELSE 0 END)     AS in_line_wip
  FROM p GROUP BY shift_id
)
SELECT e.shift_id
FROM fact_shift_end e
LEFT JOIN derived d ON d.shift_id = e.shift_id
WHERE e.arrived_n <> e.completed_n + e.rejected_n
                    + e.induct_queue_n + e.in_line_wip_n
   OR e.in_line_wip_n > 4 + 3 * 5
   OR d.shift_id IS NULL
   OR d.arrived      <> e.arrived_n
   OR d.completed    <> e.completed_n
   OR d.rejected     <> e.rejected_n
   OR d.induct_queue <> e.induct_queue_n
   OR d.in_line_wip  <> e.in_line_wip_n;
WITH p AS (
  SELECT a.shift_id, a.parcel_id,
         COUNT(f.station_id) AS steps_logged,
         MAX(CASE WHEN f.outcome = 'reject' THEN 1 ELSE 0 END) AS rejected,
         MAX(CASE WHEN st.step_order = (SELECT MAX(step_order) FROM dim_station)
                   AND f.outcome = 'good' AND NOT f.censored
                  THEN 1 ELSE 0 END) AS completed
  FROM fact_arrival a
  LEFT JOIN fact_parcel_step f
    ON f.shift_id = a.shift_id AND f.parcel_id = a.parcel_id
  LEFT JOIN dim_station st ON st.station_id = f.station_id
  GROUP BY a.shift_id, a.parcel_id
), derived AS (
  SELECT shift_id,
         COUNT(*)       AS arrived,
         SUM(completed) AS completed,
         SUM(rejected)  AS rejected,
         SUM(CASE WHEN steps_logged = 0 THEN 1 ELSE 0 END) AS induct_queue,
         SUM(CASE WHEN steps_logged > 0 AND completed = 0
                   AND rejected = 0 THEN 1 ELSE 0 END)     AS in_line_wip
  FROM p GROUP BY shift_id
)
SELECT e.shift_id
FROM fact_shift_end e
LEFT JOIN derived d ON d.shift_id = e.shift_id
WHERE e.arrived_n <> e.completed_n + e.rejected_n
                    + e.induct_queue_n + e.in_line_wip_n
   OR e.in_line_wip_n > 4 + 3 * 5
   OR d.shift_id IS NULL
   OR d.arrived      <> e.arrived_n
   OR d.completed    <> e.completed_n
   OR d.rejected     <> e.rejected_n
   OR d.induct_queue <> e.induct_queue_n
   OR d.in_line_wip  <> e.in_line_wip_n;

The dashboard

Tableau Public reads files, not databases, so I will export CSV files from DuckDB: station_shift with shift_start_local added, parcel_journey, the per-parcel waits from Q4 with scenario and the censored flag, and the outputs of Q2, Q3, and Q5 for reconciliation. The three detail tables are related on shift rather than joined: they have different grains, and a join would repeat every step-shift row once per parcel. Four views answer two questions at the top, where is the constraint, and what does it cost the cut-off?

The calculated fields:

[Active s]          = [running_s] + [down_s]
[Is constraint]     = [Active s] = { FIXED [shift_id] : MAX([Active s]) }
[OEE]               = SUM([ideal_good_s])   / SUM([planned_s])
[Availability]      = SUM([run_s])          / SUM([planned_s])
[Performance]       = SUM([ideal_output_s]) / SUM([run_s])
[Quality]           = SUM([good_units])     / SUM([total_units])
[Dispatchable]      = IIF(NOT [rejected], 1, 0)
[Staged by cut-off] = IIF([staged_s] <= [cutoff_s], 1, 0)
[Cut-off share]     = SUM([Staged by cut-off]) / SUM([Dispatchable])
[Active s]          = [running_s] + [down_s]
[Is constraint]     = [Active s] = { FIXED [shift_id] : MAX([Active s]) }
[OEE]               = SUM([ideal_good_s])   / SUM([planned_s])
[Availability]      = SUM([run_s])          / SUM([planned_s])
[Performance]       = SUM([ideal_output_s]) / SUM([run_s])
[Quality]           = SUM([good_units])     / SUM([total_units])
[Dispatchable]      = IIF(NOT [rejected], 1, 0)
[Staged by cut-off] = IIF([staged_s] <= [cutoff_s], 1, 0)
[Cut-off share]     = SUM([Staged by cut-off]) / SUM([Dispatchable])
[Active s]          = [running_s] + [down_s]
[Is constraint]     = [Active s] = { FIXED [shift_id] : MAX([Active s]) }
[OEE]               = SUM([ideal_good_s])   / SUM([planned_s])
[Availability]      = SUM([run_s])          / SUM([planned_s])
[Performance]       = SUM([ideal_output_s]) / SUM([run_s])
[Quality]           = SUM([good_units])     / SUM([total_units])
[Dispatchable]      = IIF(NOT [rejected], 1, 0)
[Staged by cut-off] = IIF([staged_s] <= [cutoff_s], 1, 0)
[Cut-off share]     = SUM([Staged by cut-off]) / SUM([Dispatchable])
  • OEE and its three factors by step for one selected shift, coloured by [Is constraint].

  • Shifts ranked first, as SUM(INT([Is constraint])) by scenario and step: the check against the planted answers. It must equal shifts_ranked_first from Q3.

  • Share of dispatchable parcels staged before the cut-off, by scenario, with staged-late and not-staged counts beside it, and a route breakdown on demand.

  • 90th-percentile wait at Induct, by scenario, marked as a lower bound whenever parcels were still waiting.

Step always stays on the OEE views, because planned_s and run_s are semi-additive and an all-steps OEE built from them would be wrong. In Tableau, a parcel with no staged time gives a null comparison, which IIF returns as null and SUM skips, matching the SQL. To reconcile, I compare the Tableau figures with the exported DuckDB outputs: per step and scenario, total units, good units, OEE to four decimal places, and shifts ranked first must match exactly, and per scenario, the dispatchable count and the cut-off share to four decimal places must match too. Tableau’s PERCENTILE may interpolate differently from DuckDB’s quantile_cont, so the p90 only has to agree within that difference.

What I will check

  • Whether Bag ranks first in most shifts of scenario A, Sort to route in most shifts of B, and Sort to route again in most shifts of C, where it does not have the slowest cycle.

  • Whether the step with the highest or lowest OEE is the same step as the constraint, and, where it is not, what the starved and blocked shares say about why.

  • How the share staged before the cut-off differs between the three scenarios, and whether the misses are mostly late or mostly never staged.

  • Whether the two OEE calculations agree on every row, whether all seven checks return zero rows, and whether Tableau and SQL agree on the reconciliation figures.

  • What breaks on the first load, if anything, and how I fix it.

Reference: C. Roser, M. Nakano, and M. Tanaka, “A practical bottleneck detection method”, Proceedings of the 2001 Winter Simulation Conference.

Drafted with AI assistance; I type and run the SQL and the simulator myself, and every number added later will come from my own run.

📍Aachen, Germany
#DataAnalytics#SQL#DuckDB#Tableau#Simulation#DataModelling#Python#LastMile
Location