Skip to content

Truncate interferes with transaction and slows down import. #129

Open
@mrschuster

Description

@mrschuster

When using MySQL and loading yaml data, the tables are cleared via "TRUNCATE". This is a DDL statement in MySQL and seems to break the surrounding transaction in Rails. In consequence, the INSERT statements get very slow on my system.

Importing about 500.000 records takes two hours. When I replace the TRUNCATE by a DELETE statement, the surrounding transaction works fine and the import is done within minutes. The additional time for the DELETE instead of TRUNCATE is negligible. I thus suggest to either always use a "DELETE" statement or to put the transaction block around the "load_records" call.

I used rails 5.1.5 with mysql2 gem 0.4.10 to produce the issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions