However, on its own, template databases are not fast enough for our use case. The time it takes to create a new database from a template database is still too high for running thousands of tests:
postgres=# CREATE DATABASE foo TEMPLATE contra;
CREATE DATABASE
Time: 1999.758 ms (00:02.000)
So no. They say this adds ~33 minutes to running their tests.
You can utilize all technics from article with the help of TestContainers.
They will help with setting up DB and providing connection strings to running images