-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
We have about 150 tables and are using PostgreSQL. After switching to a cloud development VM with probable slower Hard Drive access, we noticed a delay for starting the test suite each time.
We saw the TRUNCATE table statements in Test log:

And found, that factory_bot-preload will truncate all table every time. In sum, that took us 3 extra seconds boot time.
Environment
- Ruby 3.3.0
- Rails 7.1.3.2
- PG 16.2
- Ubuntu 22 Cloud VM - 8 core, 32 GB RAM - PgTune config applied.
Workaround
We only use 3 preload factories that touches only 4 tables, so we overrode the tables that FactoryBot::Preload truncates:
# spec_helper / test_helper
module FactoryBot
module Preload
def self.active_record_names
%w[organisations domains users memberships]
end
end
end
Ideas for a full fix
- Maybe make the tables configurable
- Faster SSD / No CoudVM but local or Bare Metal needed
- Maybe better to batch all truncations into one call?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels