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

Issue fork drupal-2857359

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tamasd created an issue. See original summary.

Boobaa’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Could you please describe what the problem really is and how to easily trigger it?

tamasd’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
1.59 KB

Status: Needs review » Needs work

The last submitted patch, 3: row_format_dynamic_innodb.patch, failed testing.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

arnested’s picture

Status: Needs work » Needs review
Issue tags: -utf8mb4 +Needs tests
FileSize
1.22 KB

I 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:

  $databases['default']['default'] = array (
    'database' => 'databasename',
    'username' => 'sqlusername',
    'password' => 'sqlpassword',
    'host' => 'localhost',
    'port' => '3306',
    'driver' => 'mysql',
    'prefix' => '',
    'collation' => 'utf8mb4_general_ci',
    'row_format' => 'compressed',
  );

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.

arnested’s picture

Title: Use ROW_FORMAT=dynamic with InnoDB » Make ROW_FORMAT configurable
Category: Task » Feature request
Issue summary: View changes
Issue tags: -Needs tests

I 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.

arnested’s picture

FileSize
1.64 KB

Updated patch where the new option is documented in default.settings.php.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jcnventura’s picture

For those using composer-patches, patch in #7 is the one to include...

arnested’s picture

Re-rolled patch to 8.8.x.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

mvc’s picture

We'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

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

cosolom’s picture

Status: Needs review » Needs work

The last submitted patch, 20: drupal-row_format-2857359-20.patch, failed testing. View results

murilohp’s picture

Just fixing the fail test and add some more documentation here, it would be nice to have other thoughts regarding the tests and the solution.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

jcnventura’s picture

Uploading 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.

jcnventura’s picture

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
162 bytes

The 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.

arnested’s picture

Status: Needs work » Needs review
FileSize
1.77 KB

Rerolled for 10.1.x and improved comments a bit.

arnested’s picture

Status: Needs review » Needs work

The last submitted patch, 28: drupal-row_format-2857359-28.patch, failed testing. View results

arnested’s picture

Status: Needs work » Needs review

The one error is because of the change to default.settings.-php which makes CI fail on comparing it to duplicated default.settings.-php in Scaffold. See #3075954.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests, +Needs Review Queue Initiative, +Needs issue summary update, +Needs change record

This 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.

arnested’s picture

Issue summary: View changes
  • Added an issue branch / merge request.
  • Updated the issue summary.
arnested’s picture

Issue summary: View changes
Status: Needs work » Needs review

Updated issue summary.

Fixed failing test case.

arnested’s picture

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs tests

Posted in #testing for testing and @FeyP made the suggestion

Not sure about the settings file, maybe there are some tests in core to check that too. But even if not, I don't think it's untestable. Just from the top of my head, absolutely untested: You could start by getting the currently active connection info with Drupal\Core\Database\Database::getConnectionInfo(). Then check, if you're testing on mysql by checking the driver (maybe there are other ways for limiting database specific tests to the correct database, could check core for possible examples?). Then you could modify the row format and create a new database connection using Drupal\Core\Database\Database::addConnectionInfo(), then set this as the active connection, create a table (or install a test module that defines a table) and then query the information schema for the row format in use and check that it matches. Something like
SELECT row_format FROM information_schema.tables`WHERE table_schema=DATABASE() and table_name='test_table';
should do the trick.

Think that's a good start for the tests.

arnested’s picture

Status: Needs work » Needs review

Thank 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!

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

Ran the test without the fix and the first fails

Expected :'Compact'
Actual :'Dynamic'

Which is expected.

Good job on the test!

daffie’s picture

Status: Reviewed & tested by the community » Closed (won't fix)

I 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.