database_cleaner-active_record icon indicating copy to clipboard operation
database_cleaner-active_record copied to clipboard

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

Open joevandyk opened this issue 11 years ago • 1 comments
trafficstars

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

set session_replication_role='replica';

joevandyk avatar Apr 14 '14 16:04 joevandyk

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

joevandyk avatar Oct 16 '14 04:10 joevandyk