Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(migrations): on cockroach db wrap migration execution on the shadow db into a transaction to speed it up #5138

Merged
merged 3 commits into from
Jan 29, 2025

Conversation

FGoessler
Copy link
Contributor

@FGoessler FGoessler commented Jan 28, 2025

This PR attempts to mitigate prisma/prisma#12384 by applying the "run DDL statements in transaction" workaround for our shadow db creation. This should significantly speed up commands like prisma migrate dev for CockroachDB users.

Prisma needs the shadow db to have a reference point to compare the current with the desired state of the database. These shadow databases get created from scratch every time and are usually very fast to setup, but not on CockroachDB.

Note that we do NOT apply this transaction workaround when interfacing with the user's production database when actually applying the migrations.

/integration

Copy link

codspeed-hq bot commented Jan 28, 2025

CodSpeed Performance Report

Merging #5138 will not alter performance

Comparing fix/cockroachdb-slow-migrations-workaround (7f2ebe4) with main (75c3406)

Summary

✅ 11 untouched benchmarks

Copy link
Contributor

github-actions bot commented Jan 28, 2025

WASM Query Engine file Size

Engine This PR Base branch Diff
Postgres 2.120MiB 2.120MiB 0.000B
Postgres (gzip) 848.486KiB 848.487KiB -1.000B
Mysql 2.082MiB 2.082MiB 0.000B
Mysql (gzip) 834.399KiB 834.400KiB -1.000B
Sqlite 1.990MiB 1.990MiB 0.000B
Sqlite (gzip) 797.975KiB 797.975KiB 0.000B

@jacek-prisma
Copy link
Contributor

Do we have confidence this actually makes a difference? I see it takes about the same amount of time on CI:
https://github.com/prisma/prisma-engines/actions/runs/13018471970/job/36313446720
https://github.com/prisma/prisma-engines/actions/runs/13011750014/job/36290928973

@FGoessler
Copy link
Contributor Author

Do we have confidence this actually makes a difference? I see it takes about the same amount of time on CI: https://github.com/prisma/prisma-engines/actions/runs/13018471970/job/36313446720 https://github.com/prisma/prisma-engines/actions/runs/13011750014/job/36290928973

On my local example I get from ~2min to ~10sec for a prisma migrate dev. :)

@FGoessler FGoessler marked this pull request as ready for review January 29, 2025 15:45
@FGoessler FGoessler requested a review from a team as a code owner January 29, 2025 15:45
@FGoessler FGoessler requested review from wmadden and removed request for a team January 29, 2025 15:45
@FGoessler FGoessler added this to the 6.4.0 milestone Jan 29, 2025
@FGoessler FGoessler merged commit 4767cae into main Jan 29, 2025
385 checks passed
@FGoessler FGoessler deleted the fix/cockroachdb-slow-migrations-workaround branch January 29, 2025 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants