Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ENV["SKIP_TEST_DATABASE_TRUNCATE"] flag to speed up multi-process test runs #51686

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions activerecord/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Add ENV["SKIP_TEST_DATABASE_TRUNCATE"] flag to speed up multi-process test runs on large DBs when all tests run within default txn. (This cuts ~10s from the test run of HEY when run by 24 processes against the 178 tables, since ~4,000 table truncates can then be skipped.)

*DHH*

* Added support for recursive common table expressions.

```ruby
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/tasks/database_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def reconstruct_from_schema(db_config, format = ActiveRecord.schema_format, file

with_temporary_pool(db_config, clobber: true) do
if schema_up_to_date?(db_config, format, file)
truncate_tables(db_config)
truncate_tables(db_config) unless ENV["SKIP_TEST_DATABASE_TRUNCATE"]
else
purge(db_config)
load_schema(db_config, format, file)
Expand Down