Optimize sqlite-to-postgres migration speed for large tables via temporary constraint suspension #1824
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces an optimization to improve the migration speed from SQLite to PostgreSQL for large tables. It temporarily disables constraints during the migration process by dropping constraints before copying data and adding them back afterwards, allowing for faster data transfer.
1289s
234.54s
1289.337736334s
(67816 rows/second)6.66825ms
Copied 87437248 rows from pstat table in
147.218779125s
(593927 rows/second)Add constraints for table pstat in
87.332639042s
46s
14.05s
46.025009083s
(79894 rows/second)1.851375ms
Copied 3677103 rows from raw_self_profile table in
7.032711416s
(522857 rows/second)Add constraints for table raw_self_profile in
7.020468166s
Note: This approach prioritizes speed over data integrity. However, since we are migrating from an existing database, the risk of compromising data integrity is likely minimal in this specific case.