Commit 1fb62ccc authored by catch's avatar catch
Browse files

Issue #2510438 by quietone, jungle, ravi.shankar, ankithashetty, longwave,...

Issue #2510438 by quietone, jungle, ravi.shankar, ankithashetty, longwave, johnwebdev, catch, daffie, Berdir, Fabianx, cilefen: Remove 'all' index from {key_value_expire} - serves no purpose and negatively impacts performance
parent 5a95baad
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -226,7 +226,6 @@ public static function schemaDefinition() {
      ],
      'primary key' => ['collection', 'name'],
      'indexes' => [
        'all' => ['name', 'collection', 'expire'],
        'expire' => ['expire'],
      ],
    ];
+10 −0
Original line number Diff line number Diff line
@@ -179,3 +179,13 @@ function system_post_update_delete_rss_settings() {
    ->clear('langcode')
    ->save();
}

/**
 * Drop the 'all' index on the 'key_value_expire' table.
 */
function system_post_update_remove_key_value_expire_all_index() {
  $schema = \Drupal::database()->schema();
  if ($schema->tableExists('key_value_expire')) {
    $schema->dropIndex('key_value_expire', 'all');
  }
}
+35 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\system\Functional\Update;

use Drupal\FunctionalTests\Update\UpdatePathTestBase;

/**
 * Tests that 'all' index is dropped from the 'key_value_expire' table.
 *
 * @group Update
 * @see system_post_update_remove_key_value_expire_all_index()
 */
class DropIndexAllOnKeyValueExpireTableUpdateTest extends UpdatePathTestBase {

  /**
   * {@inheritdoc}
   */
  protected function setDatabaseDumpFiles() {
    $this->databaseDumpFiles = [
      dirname(__DIR__, 3) . '/fixtures/update/drupal-8.8.0.bare.standard.php.gz',
    ];
  }

  /**
   * Tests that 'all' index is dropped from the 'key_value_expire' table.
   */
  public function testUpdate() {
    $schema = \Drupal::database()->schema();

    $this->assertTrue($schema->indexExists('key_value_expire', 'all'));
    $this->runUpdates();
    $this->assertFalse($schema->indexExists('key_value_expire', 'all'));
  }

}