tmpfs for a test database, and the flush settings that matter

A test database is disposable, so paying for durability is paying for a guarantee about data that is deleted at the end of the run.

services:
  mysql-test:
    image: mysql:8.0
    tmpfs:
      - /var/lib/mysql:rw,size=1g       # size is NOT optional
    command: >-
      --innodb-flush-log-at-trx-commit=0
      --innodb-flush-method=nosync
      --innodb-doublewrite=0
      --skip-innodb-adaptive-hash-index

Most of the improvement is the flush settings rather than the tmpfs — durability is what makes a write slow, and turning it off is acceptable only because losing the data is the intended outcome. The size limit is required: without it a runaway test inserting a million rows fills host memory, and the failure is the machine rather than the test. This configuration must be unreachable from the production compose file.