Problem/Motivation
It is not possible to configure MySQL to use a (different) row format. In some cases, you might need MySQL to use a row format than the default "dynamic", e.g. "compressed" to reduce disk usage.
Steps to reproduce
There is no current way to achieve this.
Proposed resolution
Make it possible to configure MySQL's ROW_FORMAT
in the database settings similar to how it is possible to configure collation:
$databases['default']['default'] = [
'database' => 'databasename',
'username' => 'sqlusername',
'password' => 'sqlpassword',
'host' => 'localhost',
'port' => '3306',
'driver' => 'mysql',
'prefix' => '',
'collation' => 'utf8mb4_general_ci',
'row_format' => 'compressed',
];
Remaining tasks
If possible, there should be a test case. But I don't think there is a way to test this in the current CI setup. The somewhat similar feature for database collation is also not covered by tests.
So in short: nothing more to be done.
User interface changes
None.
API changes
Adds the row_format
key to the database configuration in settings.php
.
Data model changes
None.
Release notes snippet
MySQL's row format is now configurable in the database settings
Comment | File | Size | Author |
---|
Issue fork drupal-2857359
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 10.1.x changes, plain diff MR !3760
- 2857359-make-rowformat-configurable changes, plain diff MR !3759
Comments
Comment #2
BoobaaCould you please describe what the problem really is and how to easily trigger it?
Comment #3
tamasd CreditAttribution: tamasd at Pronovix commentedComment #7
arnested CreditAttribution: arnested at Reload commentedI think Dynamic is already the default row format for InnoDB: https://dev.mysql.com/doc/refman/8.0/en/innodb-row-format-specification....
I don't know when it was introduced as default though so there might be a need for specifying it explicitly with older MySQLs.
Hard coding
dynamic
doesn't seem very flexible though.As an example I have some sites where we need to cut down on disk usage and therefor use row format
compressed
(depends on file format Barracuda).I suggest making it an option in the database settings similar to collation:
I have made a patch doing that.
The patch lacks a test case. I'm still researching how to test this (there is no similar test for collation unfortunately) -- ideas and pointers would be welcome.
Comment #8
arnested CreditAttribution: arnested at Reload commentedI have looked into writing a test for this and I can't figure out how to do that. I haven't found a way to manipulate database settings for a test (it is possible to I haven't looked hard enough). The feature is very similar to the collation feature and that feature isn't covered by a test either.
Comment #9
arnested CreditAttribution: arnested at Reload commentedUpdated patch where the new option is documented in
default.settings.php
.Comment #12
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedFor those using composer-patches, patch in #7 is the one to include...
Comment #13
arnested CreditAttribution: arnested at Reload commentedRe-rolled patch to 8.8.x.
Comment #15
mvcWe're doing the equivalent in D7 because our DBAs insisted on using the compressed row format. Our db servers are I/O bound (as they usually are) so the smaller files are well worth the extra processing time. The patch looks about the same but I can backport it once this is accepted in D8 (or D9?). For now I've submitted a patch to utf8mb4-convert to handle this case: #3088343: Multiple patches: include additional tables, use compressed row format, use utf8mb4_bin only where needed
Comment #20
cosolom CreditAttribution: cosolom commentedRerolled for D9.4
Comment #22
murilohp CreditAttribution: murilohp at CI&T commentedJust fixing the fail test and add some more documentation here, it would be nice to have other thoughts regarding the tests and the solution.
Comment #24
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedUploading a version of #22 that can be applied via composer patches.
At least until #3075954: Remove duplicate scaffold files is not applied. If that happens, then this is the patch to use.
Comment #25
jcnventura CreditAttribution: jcnventura at 1xINTERNET commentedComment #27
needs-review-queue-bot CreditAttribution: needs-review-queue-bot as a volunteer commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #28
arnested CreditAttribution: arnested at Reload commentedRerolled for 10.1.x and improved comments a bit.
Comment #29
arnested CreditAttribution: arnested at Reload commentedComment #31
arnested CreditAttribution: arnested at Reload commentedThe one error is because of the change to
default.settings.-php
which makes CI fail on comparing it to duplicateddefault.settings.-php
in Scaffold. See #3075954.Comment #32
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
This needs an issue summary update as we are adding something to the database layer. What's the proposed solution to tackle this issue? Remaining tasks?
This will need test coverage as well
Once everything is agreed a change record will be needed to announce this change.
Comment #36
arnested CreditAttribution: arnested at Reload commentedComment #37
arnested CreditAttribution: arnested at Reload commentedUpdated issue summary.
Fixed failing test case.
Comment #38
arnested CreditAttribution: arnested at Reload commentedComment #39
smustgrave CreditAttribution: smustgrave at Mobomo commentedPosted in #testing for testing and @FeyP made the suggestion
Think that's a good start for the tests.
Comment #40
arnested CreditAttribution: arnested at Reload commentedThank you for the hints, @smustgrave and @FeyP!
I managed to create a working test case for this now. I couldn't have done it without you!
Comment #41
smustgrave CreditAttribution: smustgrave at Mobomo commentedRan the test without the fix and the first fails
Expected :'Compact'
Actual :'Dynamic'
Which is expected.
Good job on the test!
Comment #42
daffie CreditAttribution: daffie at Finalist commentedI do not see, why we should do this issue. In the issue summary is the reason given that we should do it, because it will reduce disk use. As disk are super cheap, this is not a good enough reason to do this issue. Cahnging the status to will not fix. If somebody has a better reason for why we should do this issue, than please add it and change to status to needs work.