diff --git a/modules/search_api_db/src/DatabaseCompatibility/DatabaseCompatibilityHandlerInterface.php b/modules/search_api_db/src/DatabaseCompatibility/DatabaseCompatibilityHandlerInterface.php
index 2a3d36f3..d96431d5 100644
--- a/modules/search_api_db/src/DatabaseCompatibility/DatabaseCompatibilityHandlerInterface.php
+++ b/modules/search_api_db/src/DatabaseCompatibility/DatabaseCompatibilityHandlerInterface.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\search_api_db\DatabaseCompatibility;
 
+use Drupal\Core\Database\Connection;
+
 /**
  * Bundles methods for resolving DBMS-specific differences.
  *
@@ -19,6 +21,17 @@
    */
   public function getDatabase();
 
+  /**
+   * Creates a clone of this service for the given database.
+   *
+   * @param \Drupal\Core\Database\Connection $database
+   *   A database of a type compatible with this class.
+   *
+   * @return static
+   *   A clone of this service class for the given database.
+   */
+  public function getCloneForDatabase(Connection $database);
+
   /**
    * Reacts to a new table being created.
    *
diff --git a/modules/search_api_db/src/DatabaseCompatibility/GenericDatabase.php b/modules/search_api_db/src/DatabaseCompatibility/GenericDatabase.php
index c6e02340..f52bb945 100644
--- a/modules/search_api_db/src/DatabaseCompatibility/GenericDatabase.php
+++ b/modules/search_api_db/src/DatabaseCompatibility/GenericDatabase.php
@@ -45,6 +45,15 @@ public function getDatabase() {
     return $this->database;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getCloneForDatabase(Connection $database) {
+    $service = clone $this;
+    $service->database = $database;
+    return $service;
+  }
+
   /**
    * {@inheritdoc}
    */
@@ -59,5 +68,4 @@ public function preprocessIndexValue($value, $type = 'text') {
     }
     return Unicode::strtolower($this->transliterator->transliterate($value));
   }
-
 }
diff --git a/modules/search_api_db/src/Plugin/search_api/backend/Database.php b/modules/search_api_db/src/Plugin/search_api/backend/Database.php
index 5532e63b..71a3b988 100644
--- a/modules/search_api_db/src/Plugin/search_api/backend/Database.php
+++ b/modules/search_api_db/src/Plugin/search_api/backend/Database.php
@@ -197,12 +197,23 @@ public static function create(ContainerInterface $container, array $configuratio
 
     // For a new backend plugin, the database might not be set yet. In that case
     // we of course also don't need a DBMS compatibility handler.
-    if ($backend->getDatabase()) {
+    $database = $backend->getDatabase();
+    if ($database) {
       $dbms_compatibility_handler = $container->get('search_api_db.database_compatibility');
       // Make sure that we actually provide a handler for the right database,
-      // otherwise fall back to the generic handler.
-      if ($dbms_compatibility_handler->getDatabase() != $backend->getDatabase()) {
-        $dbms_compatibility_handler = new GenericDatabase($backend->getDatabase(), $container->get('transliteration'));
+      // otherwise create the right service manually. (This is the case if the
+      // user didn't pick the default database.)
+      if ($dbms_compatibility_handler->getDatabase() != $database) {
+        $database_type = $database->databaseType();
+        $service_id = "$database_type.search_api_db.database_compatibility";
+        if ($container->has($service_id)) {
+          /** @var \Drupal\search_api_db\DatabaseCompatibility\DatabaseCompatibilityHandlerInterface $dbms_compatibility_handler */
+          $dbms_compatibility_handler = $container->get($service_id);
+          $dbms_compatibility_handler = $dbms_compatibility_handler->getCloneForDatabase($database);
+        }
+        else {
+          $dbms_compatibility_handler = new GenericDatabase($database, $container->get('transliteration'));
+        }
       }
       $backend->setDbmsCompatibilityHandler($dbms_compatibility_handler);
     }
@@ -210,16 +221,6 @@ public static function create(ContainerInterface $container, array $configuratio
     return $backend;
   }
 
-  /**
-   * Retrieves the database connection used by this backend.
-   *
-   * @return \Drupal\Core\Database\Connection
-   *   The database connection.
-   */
-  public function getDatabase() {
-    return $this->database;
-  }
-
   /**
    * Returns the module handler to use for this plugin.
    *
@@ -230,6 +231,16 @@ public function getModuleHandler() {
     return $this->moduleHandler ?: \Drupal::moduleHandler();
   }
 
+  /**
+   * Retrieves the database connection used by this backend.
+   *
+   * @return \Drupal\Core\Database\Connection
+   *   The database connection.
+   */
+  public function getDatabase() {
+    return $this->database;
+  }
+
   /**
    * Sets the module handler to use for this plugin.
    *
