DatabaseCleaner / database_cleaner-active_record

Strategies for cleaning databases using ActiveRecord. Can be used to ensure a clean state for testing.
MIT License
62 stars 64 forks source link

disabling referential integrity with postgresql is faster by setting session_replication_role='replica' #26

Open joevandyk opened 10 years ago

joevandyk commented 10 years ago

For large databases, this is way faster than disabling/enabling all the triggers.

set session_replication_role='replica';

joevandyk commented 10 years ago

Also, instead of executing the DELETE statements one by one, faster to do it in a single WITH query:

with table_1 as (delete from users), table_2 as (delete from orders) select 1