Search code examples
testingschemacockroachdb

Speed of CockroachDB schema changes during unit tests


I have issues with schema changes in my testing infrastructure. We use a unit test framework, and truncate our database between each unit test. I've noticed that running a series of CREATE statements is very slow as well, specifically duplicating a database for running parallel tests. I'm finding it's taking upwards of 10 minutes to duplicate a database 10 times (I'm using SHOW CREATE ALL TABLES and running those statements).


Solution

  • The problem with CockroachDB schema changes getting slow in tests is known, but there are some workarounds. See this guide with some recommended settings for unit tests, which should help address some of the problems: https://www.cockroachlabs.com/docs/stable/local-testing.html#use-a-local-single-node-cluster-with-in-memory-storage

    Future releases (that is, v22.2 and later) will continue improving the performance of schema changes when repeatedly dropping and creating tables.