Opened 10 months ago

Closed 9 months ago

Last modified 9 months ago

#35015 closed Cleanup/optimization (fixed)

Update MySQL migration documentation for Mysql 8

Reported by: Nicolas Lupien Owned by: Nicolas Lupien
Component: Documentation Version: 5.0
Severity: Normal Keywords: mysql
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Nicolas Lupien)

Now that Django dropped support for MySQL 5.7, I think the documentation is no longer valid.

MySQL lacks support for transactions around schema alteration operations, meaning that if a migration fails to apply you will have to manually unpick the changes in order to try again (it’s impossible to roll back to an earlier point).

In addition, MySQL will fully rewrite tables for almost every schema operation and generally takes a time proportional to the number of rows in the table to add or remove columns. On slower hardware this can be worse than a minute per million rows - adding a few columns to a table with just a few million rows could lock your site up for over ten minutes.

Finally, MySQL has relatively small limits on name lengths for columns, tables and indexes, as well as a limit on the combined size of all columns an index covers. This means that indexes that are possible on other backends will fail to be created under MySQL.

https://docs.djangoproject.com/en/5.0/topics/migrations/#mysql

Change History (11)

comment:1 by Nicolas Lupien, 10 months ago

Description: modified (diff)

comment:2 by Simon Charette, 10 months ago

MySQL lacks support for transactions around schema alteration operations, meaning that if a migration fails to apply you will have to manually unpick the changes in order to try again (it’s impossible to roll back to an earlier point).

This is still true.

In addition, MySQL will fully rewrite tables for almost every schema operation and generally takes a time proportional to the number of rows in the table to add or remove columns. On slower hardware this can be worse than a minute per million rows - adding a few columns to a table with just a few million rows could lock your site up for over ten minutes.

That's no longer true for most operations and should be adjusted. I guess we could link to MySQL's Online DDL operations docs.

Finally, MySQL has relatively small limits on name lengths for columns, tables and indexes, as well as a limit on the combined size of all columns an index covers. This means that indexes that are possible on other backends will fail to be created under MySQL.

I'm pretty sure this is still true to a certain extent.


Which parts of the documentation you believe are not accurate? Would you be interested in submitting a patch that addresses the inaccuracies?

comment:3 by Nicolas Lupien, 10 months ago

Which parts of the documentation you believe are not accurate?

I'm not a MySQL expert, it's just that reading this section of the docs seemed outdated. Like you pointed out, many DDL operations in MySQL 8 happens without locking.

Would you be interested in submitting a patch that addresses the inaccuracies?

Yes, I'll be happy to do the research and submit a patch!

comment:4 by Mariusz Felisiak, 10 months ago

Keywords: mysql added
Resolution: needsinfo
Status: newclosed
Type: UncategorizedCleanup/optimization

Maybe a middle sentence:

In addition, MySQL will fully rewrite tables for almost every schema operation and generally takes a time proportional to the number of rows in the table to add or remove columns. On slower hardware this can be worse than a minute per million rows - adding a few columns to a table with just a few million rows could lock your site up for over ten minutes.

is a bit inaccurate, but you haven't presented any references to prove it. Also, generally this paragraph is still valid. Closing as "needsinfo" for now. Feel-free to investigate and provide details what and where is wrong in docs.

comment:5 by Nicolas Lupien, 10 months ago

Resolution: needsinfo
Status: closednew

This is my first contribution, let me know if I missed something. https://github.com/django/django/pull/17582

comment:6 by Nicolas Lupien, 9 months ago

Has patch: set
Owner: changed from nobody to Nicolas Lupien
Status: newassigned

comment:7 by Simon Charette, 9 months ago

Thank you for your patch Nicolas! I think the wording for the online DDL operations section is great but that we should keep the section about InnoDB limitations.

comment:8 by Simon Charette, 9 months ago

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

comment:9 by Mariusz Felisiak, 9 months ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:10 by Mariusz Felisiak <felisiak.mariusz@…>, 9 months ago

Resolution: fixed
Status: assignedclosed

In d4c58368:

Fixed #35015 -- Updated MySQL notes in migrations topic.

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 9 months ago

In bc60b1e:

[5.0.x] Fixed #35015 -- Updated MySQL notes in migrations topic.

Backport of d4c583682e7afc2b4e953b8c85af17f1c1514ba9 from main

Note: See TracTickets for help on using tickets.
Back to Top