MySQL, self-join  | 100% faster/100% less memory
\nSELECT s.machine_id, ROUND(AVG(e.timestamp-s.timestamp), 3) AS processing_time\nFROM Activity s JOIN Activity e ON\n    s.machine_id = e.machine_id AND s.proc
```\nSELECT s.machine_id, ROUND(AVG(e.timestamp-s.timestamp), 3) AS processing_time\nFROM Activity s JOIN Activity e ON\n    s.machine_id = e.machine_id AND s.process_id = e.process_id AND\n    s.activity_type = \'start\' AND e.activity_type = \'end\'\nGROUP BY s.machine_id\n```
['MySQL']