diff --git a/core/core.services.yml b/core/core.services.yml
index f8f73a764ff1cce6d54274ae3e51dd2b328f819c..dd8d66a374b789967c970d5c464ea169a1a97f1e 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -1670,13 +1670,3 @@ services:
   pager.parameters:
     class: Drupal\Core\Pager\PagerParameters
     arguments: ['@request_stack']
-  select_extender_factory.pager:
-    class: Drupal\Core\Database\Query\PagerSelectExtenderFactory
-    arguments: ['@pager.manager']
-    tags:
-      - { name: backend_overridable }
-  select_extender_factory.table_sort:
-    class: Drupal\Core\Database\Query\TableSortExtenderFactory
-    arguments: ['@request_stack']
-    tags:
-      - { name: backend_overridable }
diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php
index 5cebdd753b98b1a42d8349530fb89872c551c8a9..9d518af3d366be1d3b73d70e14a4f1725a0a323b 100644
--- a/core/lib/Drupal/Core/Database/Connection.php
+++ b/core/lib/Drupal/Core/Database/Connection.php
@@ -11,6 +11,7 @@
 use Drupal\Core\Database\Query\Truncate;
 use Drupal\Core\Database\Query\Update;
 use Drupal\Core\Database\Query\Upsert;
+use Drupal\Core\Pager\PagerManagerInterface;
 
 /**
  * Base Database API class.
@@ -1811,6 +1812,19 @@ public function getProvider(): string {
     return ($first === 'Drupal' && strtolower($second) === $second) ? $second : 'core';
   }
 
+  /**
+   * Get the pager manager service, if available.
+   *
+   * @return \Drupal\Core\Pager\PagerManagerInterface
+   *   The pager manager service, if available.
+   *
+   * @throws \Drupal\Core\DependencyInjection\ContainerNotInitializedException
+   *   If the container has not been initialized yet.
+   */
+  public function getPagerManager(): PagerManagerInterface {
+    return \Drupal::service('pager.manager');
+  }
+
   /**
    * Runs a simple query to validate json datatype support.
    *
diff --git a/core/lib/Drupal/Core/Database/Query/PagerSelectExtender.php b/core/lib/Drupal/Core/Database/Query/PagerSelectExtender.php
index e92689c345f3aaf7d00e2a7cb9260ad5b05f8fea..3620d9b5d17c9d42b1e368db07be7fc52f9ac1fb 100644
--- a/core/lib/Drupal/Core/Database/Query/PagerSelectExtender.php
+++ b/core/lib/Drupal/Core/Database/Query/PagerSelectExtender.php
@@ -3,7 +3,6 @@
 namespace Drupal\Core\Database\Query;
 
 use Drupal\Core\Database\Connection;
-use Drupal\Core\Pager\PagerManagerInterface;
 
 /**
  * Query extender for pager queries.
@@ -45,14 +44,8 @@ class PagerSelectExtender extends SelectExtender {
    *   Select query object.
    * @param \Drupal\Core\Database\Connection $connection
    *   Database connection object.
-   * @param \Drupal\Core\Pager\PagerManagerInterface $pagerManager
-   *   The pager manager service.
    */
-  public function __construct(
-    SelectInterface $query,
-    Connection $connection,
-    protected PagerManagerInterface $pagerManager
-  ) {
+  public function __construct(SelectInterface $query, Connection $connection) {
     parent::__construct($query, $connection);
 
     // Add pager tag. Do this here to ensure that it is always added before
@@ -81,7 +74,7 @@ public function execute() {
     $this->ensureElement();
 
     $total_items = $this->getCountQuery()->execute()->fetchField();
-    $pager = $this->pagerManager->createPager($total_items, $this->limit, $this->element);
+    $pager = $this->connection->getPagerManager()->createPager($total_items, $this->limit, $this->element);
     $this->range($pager->getCurrentPage() * $this->limit, $this->limit);
 
     // Now that we've added our pager-based range instructions, run the query normally.
@@ -96,7 +89,7 @@ public function execute() {
    */
   protected function ensureElement() {
     if (!isset($this->element)) {
-      $this->element($this->pagerManager->getMaxPagerElementId() + 1);
+      $this->element($this->connection->getPagerManager()->getMaxPagerElementId() + 1);
     }
   }
 
@@ -164,7 +157,7 @@ public function limit($limit = 10) {
    */
   public function element($element) {
     $this->element = $element;
-    $this->pagerManager->reservePagerElementId($this->element);
+    $this->connection->getPagerManager()->reservePagerElementId($this->element);
     return $this;
   }
 
diff --git a/core/lib/Drupal/Core/Database/Query/PagerSelectExtenderFactory.php b/core/lib/Drupal/Core/Database/Query/PagerSelectExtenderFactory.php
deleted file mode 100644
index dc8aac6069f7b05ae25db7a765d0c32b469bc5c9..0000000000000000000000000000000000000000
--- a/core/lib/Drupal/Core/Database/Query/PagerSelectExtenderFactory.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-namespace Drupal\Core\Database\Query;
-
-use Drupal\Core\Database\Connection;
-use Drupal\Core\Pager\PagerManagerInterface;
-
-/**
- * Select extender factory for pager queries.
- */
-class PagerSelectExtenderFactory {
-
-  /**
-   * Constructs a PagerSelectExtenderFactory object.
-   *
-   * @param \Drupal\Core\Pager\PagerManagerInterface $pagerManager
-   *   The pager manager service.
-   */
-  public function __construct(
-    protected PagerManagerInterface $pagerManager
-  ) {
-  }
-
-  /**
-   * Returns a query extender for pager queries.
-   *
-   * @param \Drupal\Core\Database\Query\SelectInterface $query
-   *   Select query object.
-   * @param \Drupal\Core\Database\Connection $connection
-   *   Database connection object.
-   *
-   * @return \Drupal\Core\Database\Query\PagerSelectExtender
-   *   A query extender for pager queries.
-   */
-  public function get(SelectInterface $query, Connection $connection): PagerSelectExtender {
-    return new PagerSelectExtender($query, $connection, $this->pagerManager);
-  }
-
-}
diff --git a/core/lib/Drupal/Core/Database/Query/Select.php b/core/lib/Drupal/Core/Database/Query/Select.php
index 9747a1717c0b2a48f798ec1b5c74b018e4dc8316..ac7bdd4e6f932717865ba41c1012aaa6e6694bac 100644
--- a/core/lib/Drupal/Core/Database/Query/Select.php
+++ b/core/lib/Drupal/Core/Database/Query/Select.php
@@ -320,7 +320,13 @@ public function havingCompile(Connection $connection) {
    * {@inheritdoc}
    */
   public function extend($extender_name) {
-    return \Drupal::service('select_extender_factory.' . $extender_name)->get($this, $this->connection);
+    $parts = explode('\\', $extender_name);
+    $class = end($parts);
+    $driver_class = $this->connection->getDriverClass($class);
+    if ($driver_class !== $class) {
+      return new $driver_class($this, $this->connection);
+    }
+    return new $extender_name($this, $this->connection);
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Database/Query/SelectExtender.php b/core/lib/Drupal/Core/Database/Query/SelectExtender.php
index 2cb73979f19c2cba3c1cf5b1a2af5d77a695e8c2..0681813f04cc47821b225e41282ef1322324fcb0 100644
--- a/core/lib/Drupal/Core/Database/Query/SelectExtender.php
+++ b/core/lib/Drupal/Core/Database/Query/SelectExtender.php
@@ -221,7 +221,13 @@ public function extend($extender_name) {
     // We cannot call $this->query->extend(), because with multiple extenders
     // you will replace all the earlier extenders with the last extender,
     // instead of creating list of objects that extend each other.
-    return \Drupal::service('select_extender_factory.' . $extender_name)->get($this, $this->connection);
+    $parts = explode('\\', $extender_name);
+    $class = end($parts);
+    $driver_class = $this->connection->getDriverClass($class);
+    if ($driver_class !== $class) {
+      return new $driver_class($this, $this->connection);
+    }
+    return new $extender_name($this, $this->connection);
   }
 
   /* Alter accessors to expose the query data to alter hooks. */
diff --git a/core/lib/Drupal/Core/Database/Query/TableSortExtender.php b/core/lib/Drupal/Core/Database/Query/TableSortExtender.php
index d2a1777a8b93ac8e3e350f3b39cb898ee3cfa13c..60da1b864acecf9a0cc5c8541aed52c61e549351 100644
--- a/core/lib/Drupal/Core/Database/Query/TableSortExtender.php
+++ b/core/lib/Drupal/Core/Database/Query/TableSortExtender.php
@@ -4,7 +4,6 @@
 
 use Drupal\Core\Database\Connection;
 use Drupal\Core\Utility\TableSort;
-use Symfony\Component\HttpFoundation\RequestStack;
 
 /**
  * Query extender class for tablesort queries.
@@ -12,20 +11,9 @@
 class TableSortExtender extends SelectExtender {
 
   /**
-   * Constructs a TableSortExtender object.
-   *
-   * @param \Drupal\Core\Database\Query\SelectInterface $query
-   *   Select query object.
-   * @param \Drupal\Core\Database\Connection $connection
-   *   Database connection object.
-   * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
-   *   The request stack.
+   * {@inheritdoc}
    */
-  public function __construct(
-    SelectInterface $query,
-    Connection $connection,
-    protected RequestStack $requestStack
-  ) {
+  public function __construct(SelectInterface $query, Connection $connection) {
     parent::__construct($query, $connection);
 
     // Add convenience tag to mark that this is an extended query. We have to
@@ -46,7 +34,7 @@ public function __construct(
    * @see table.html.twig
    */
   public function orderByHeader(array $header) {
-    $context = TableSort::getContextFromRequest($header, $this->requestStack->getCurrentRequest());
+    $context = TableSort::getContextFromRequest($header, \Drupal::request());
     if (!empty($context['sql'])) {
       // Based on code from \Drupal\Core\Database\Connection::escapeTable(),
       // but this can also contain a dot.
diff --git a/core/lib/Drupal/Core/Database/Query/TableSortExtenderFactory.php b/core/lib/Drupal/Core/Database/Query/TableSortExtenderFactory.php
deleted file mode 100644
index 95d3325cc5f9ddff7c2ef25fe72d53d704bc2422..0000000000000000000000000000000000000000
--- a/core/lib/Drupal/Core/Database/Query/TableSortExtenderFactory.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-namespace Drupal\Core\Database\Query;
-
-use Drupal\Core\Database\Connection;
-use Symfony\Component\HttpFoundation\RequestStack;
-
-/**
- * Select extender factory for tablesort queries.
- */
-class TableSortExtenderFactory {
-
-  /**
-   * Constructs a TableSortExtenderFactory object.
-   *
-   * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
-   *   The request stack.
-   */
-  public function __construct(
-    protected RequestStack $requestStack
-  ) {
-  }
-
-  /**
-   * Returns a query extender for tablesort queries.
-   *
-   * @param \Drupal\Core\Database\Query\SelectInterface $query
-   *   Select query object.
-   * @param \Drupal\Core\Database\Connection $connection
-   *   Database connection object.
-   *
-   * @return \Drupal\Core\Database\Query\TableSortExtender
-   *   A query extender for tablesort queries.
-   */
-  public function get(SelectInterface $query, Connection $connection): TableSortExtender {
-    return new TableSortExtender($query, $connection, $this->requestStack);
-  }
-
-}
diff --git a/core/lib/Drupal/Core/Pager/PagerManagerInterface.php b/core/lib/Drupal/Core/Pager/PagerManagerInterface.php
index c4e31f5bffc9a3f149011734be9a613975b0f92e..113fcb84302548112679095e41e53f1f17d99e09 100644
--- a/core/lib/Drupal/Core/Pager/PagerManagerInterface.php
+++ b/core/lib/Drupal/Core/Pager/PagerManagerInterface.php
@@ -29,11 +29,11 @@ interface PagerManagerInterface {
    * If the items being displayed result from a database query performed using
    * Drupal's database API, and if you have control over the construction of the
    * database query, you do not need to call this function directly; instead,
-   * you can extend the query object with the 'pager' select query extender
+   * you can extend the query object with the 'PagerSelectExtender' extender
    * before executing it. For example:
    * @code
    *   $query = $connection->select('some_table')
-   *     ->extend('pager');
+   *     ->extend(PagerSelectExtender::class);
    * @endcode
    *
    * However, if you are using a different method for generating the items to be
diff --git a/core/modules/comment/src/CommentStorage.php b/core/modules/comment/src/CommentStorage.php
index 4a8122f9c1e90737f9e3a668e608dfaba3ec6e47..6bf70252189c5dc7f1f7e2eaa77e894de16fd86f 100644
--- a/core/modules/comment/src/CommentStorage.php
+++ b/core/modules/comment/src/CommentStorage.php
@@ -5,6 +5,7 @@
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface;
 use Drupal\Core\Database\Connection;
+use Drupal\Core\Database\Query\PagerSelectExtender;
 use Drupal\Core\Entity\EntityFieldManagerInterface;
 use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
 use Drupal\Core\Entity\EntityTypeInterface;
@@ -287,7 +288,7 @@ public function loadThread(EntityInterface $entity, $field_name, $mode, $comment
       ->addMetaData('field_name', $field_name);
 
     if ($comments_per_page) {
-      $query = $query->extend('pager')
+      $query = $query->extend(PagerSelectExtender::class)
         ->limit($comments_per_page);
       if ($pager_id) {
         $query->element($pager_id);
diff --git a/core/modules/dblog/src/Controller/DbLogController.php b/core/modules/dblog/src/Controller/DbLogController.php
index 195f17b6615b283ffc1ab134d97d0508e52d6d5d..b52ed5015a2dddf44a0241ba566ddc3690b03da3 100644
--- a/core/modules/dblog/src/Controller/DbLogController.php
+++ b/core/modules/dblog/src/Controller/DbLogController.php
@@ -9,6 +9,8 @@
 use Drupal\Component\Utility\UrlHelper;
 use Drupal\Core\Controller\ControllerBase;
 use Drupal\Core\Database\Connection;
+use Drupal\Core\Database\Query\PagerSelectExtender;
+use Drupal\Core\Database\Query\TableSortExtender;
 use Drupal\Core\Datetime\DateFormatterInterface;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Form\FormBuilderInterface;
@@ -151,8 +153,8 @@ public function overview(Request $request) {
     ];
 
     $query = $this->database->select('watchdog', 'w')
-      ->extend('pager')
-      ->extend('table_sort');
+      ->extend(PagerSelectExtender::class)
+      ->extend(TableSortExtender::class);
     $query->fields('w', [
       'wid',
       'uid',
@@ -421,8 +423,8 @@ public function topLogMessages($type) {
     $count_query->condition('type', $type);
 
     $query = $this->database->select('watchdog', 'w')
-      ->extend('pager')
-      ->extend('table_sort');
+      ->extend(PagerSelectExtender::class)
+      ->extend(TableSortExtender::class);
     $query->addExpression('COUNT([wid])', 'count');
     $query = $query
       ->fields('w', ['message', 'variables'])
diff --git a/core/modules/forum/src/ForumManager.php b/core/modules/forum/src/ForumManager.php
index 29277de9e4e5f9e911acc6f8b4813818e9ae5918..3e9a16e9a6cc07478d6f9a1434c42187b4361113 100644
--- a/core/modules/forum/src/ForumManager.php
+++ b/core/modules/forum/src/ForumManager.php
@@ -4,6 +4,8 @@
 
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Database\Connection;
+use Drupal\Core\Database\Query\PagerSelectExtender;
+use Drupal\Core\Database\Query\TableSortExtender;
 use Drupal\Core\DependencyInjection\DependencySerializationTrait;
 use Drupal\Core\Entity\EntityFieldManagerInterface;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
@@ -160,8 +162,8 @@ public function getTopics($tid, AccountInterface $account) {
     }
 
     $query = $this->connection->select('forum_index', 'f')
-      ->extend('pager')
-      ->extend('table_sort');
+      ->extend(PagerSelectExtender::class)
+      ->extend(TableSortExtender::class);
     $query->fields('f');
     $query
       ->condition('f.tid', $tid)
@@ -187,7 +189,7 @@ public function getTopics($tid, AccountInterface $account) {
       $nodes = $this->entityTypeManager->getStorage('node')->loadMultiple($nids);
 
       $query = $this->connection->select('node_field_data', 'n')
-        ->extend('table_sort');
+        ->extend(TableSortExtender::class);
       $query->fields('n', ['nid']);
 
       $query->join('comment_entity_statistics', 'ces', "[n].[nid] = [ces].[entity_id] AND [ces].[field_name] = 'comment_forum' AND [ces].[entity_type] = 'node'");
diff --git a/core/modules/help_topics/src/Plugin/Search/HelpSearch.php b/core/modules/help_topics/src/Plugin/Search/HelpSearch.php
index c69d531cb05641bf1c1c865fc382bb19c2e27da1..49b0038d0d1e42d0268a2734815a8d59ba4c43f0 100644
--- a/core/modules/help_topics/src/Plugin/Search/HelpSearch.php
+++ b/core/modules/help_topics/src/Plugin/Search/HelpSearch.php
@@ -6,6 +6,7 @@
 use Drupal\Core\Access\AccessResult;
 use Drupal\Core\Config\Config;
 use Drupal\Core\Database\Connection;
+use Drupal\Core\Database\Query\PagerSelectExtender;
 use Drupal\Core\Database\StatementInterface;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\Core\Language\LanguageManagerInterface;
@@ -219,8 +220,8 @@ protected function findResults() {
       ->select('search_index', 'i')
       // Restrict the search to the current interface language.
       ->condition('i.langcode', $this->languageManager->getCurrentLanguage()->getId())
-      ->extend('search_query')
-      ->extend('pager');
+      ->extend(SearchQuery::class)
+      ->extend(PagerSelectExtender::class);
     $query->innerJoin('help_search_items', 'hsi', '[i].[sid] = [hsi].[sid] AND [i].[type] = :type', [':type' => $this->getType()]);
     if ($denied_permissions) {
       $query->condition('hsi.permission', $denied_permissions, 'NOT IN');
diff --git a/core/modules/locale/src/StringDatabaseStorage.php b/core/modules/locale/src/StringDatabaseStorage.php
index 541b1d69d5171e98e926d4b75f0c52b882cd5d10..74e94fca5d160ee85be61e572144ec962f51f38b 100644
--- a/core/modules/locale/src/StringDatabaseStorage.php
+++ b/core/modules/locale/src/StringDatabaseStorage.php
@@ -3,6 +3,7 @@
 namespace Drupal\locale;
 
 use Drupal\Core\Database\Connection;
+use Drupal\Core\Database\Query\PagerSelectExtender;
 
 /**
  * Defines a class to store localized strings in the database.
@@ -442,7 +443,7 @@ protected function dbStringSelect(array $conditions, array $options = []) {
     }
 
     if (!empty($options['pager limit'])) {
-      $query = $query->extend('pager')->limit($options['pager limit']);
+      $query = $query->extend(PagerSelectExtender::class)->limit($options['pager limit']);
     }
 
     return $query;
diff --git a/core/modules/node/src/Plugin/Search/NodeSearch.php b/core/modules/node/src/Plugin/Search/NodeSearch.php
index 3ab001a4ebc19908d618eced6d08512410f125be..0342c5f01d29c33bba4d00420feeaf332d6155cf 100644
--- a/core/modules/node/src/Plugin/Search/NodeSearch.php
+++ b/core/modules/node/src/Plugin/Search/NodeSearch.php
@@ -7,6 +7,7 @@
 use Drupal\Core\Cache\CacheableMetadata;
 use Drupal\Core\Config\Config;
 use Drupal\Core\Database\Connection;
+use Drupal\Core\Database\Query\PagerSelectExtender;
 use Drupal\Core\Database\Query\SelectExtender;
 use Drupal\Core\Database\StatementInterface;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
@@ -261,8 +262,8 @@ protected function findResults() {
     // Build matching conditions.
     $query = $this->databaseReplica
       ->select('search_index', 'i')
-      ->extend('search_query')
-      ->extend('pager');
+      ->extend(SearchQuery::class)
+      ->extend(PagerSelectExtender::class);
     $query->join('node_field_data', 'n', '[n].[nid] = [i].[sid] AND [n].[langcode] = [i].[langcode]');
     $query->condition('n.status', 1)
       ->addTag('node_access')
diff --git a/core/modules/search/search.services.yml b/core/modules/search/search.services.yml
index 107038260caf10566f728d0be8595a8d1177fd2d..8f6e2a0fcc16b0f730b47f73a8074b26f9895d10 100644
--- a/core/modules/search/search.services.yml
+++ b/core/modules/search/search.services.yml
@@ -16,15 +16,3 @@ services:
   search.text_processor:
     class: Drupal\search\SearchTextProcessor
     arguments: ['@transliteration', '@config.factory', '@module_handler']
-
-  select_extender_factory.search_query:
-    class: Drupal\search\SearchQueryFactory
-    arguments: ['@config.factory', '@search.text_processor']
-    tags:
-      - { name: backend_overridable }
-
-  select_extender_factory.views_search_query:
-    class: Drupal\search\ViewsSearchQueryFactory
-    arguments: ['@config.factory', '@search.text_processor']
-    tags:
-      - { name: backend_overridable }
diff --git a/core/modules/search/src/Plugin/views/argument/Search.php b/core/modules/search/src/Plugin/views/argument/Search.php
index 02dee62a847265bda43f7546a34906d8043832fb..ab61880e144b41da589aecbea623be45f1132760 100644
--- a/core/modules/search/src/Plugin/views/argument/Search.php
+++ b/core/modules/search/src/Plugin/views/argument/Search.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\search\Plugin\views\argument;
 
+use Drupal\search\ViewsSearchQuery;
 use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
 use Drupal\views\Plugin\views\display\DisplayPluginBase;
 use Drupal\views\ViewExecutable;
@@ -47,7 +48,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
    */
   protected function queryParseSearchExpression($input) {
     if (!isset($this->searchQuery)) {
-      $this->searchQuery = \Drupal::service('database.replica')->select('search_index', 'i')->extend('views_search_query');
+      $this->searchQuery = \Drupal::service('database.replica')->select('search_index', 'i')->extend(ViewsSearchQuery::class);
       $this->searchQuery->searchExpression($input, $this->searchType);
       $this->searchQuery->publicParseSearchExpression();
     }
diff --git a/core/modules/search/src/Plugin/views/filter/Search.php b/core/modules/search/src/Plugin/views/filter/Search.php
index 1f5325465139b9094f0a5e12f31525b0cd798168..c0b0d4516b3e9a4e852100c79ec21fba403aee26 100644
--- a/core/modules/search/src/Plugin/views/filter/Search.php
+++ b/core/modules/search/src/Plugin/views/filter/Search.php
@@ -3,6 +3,7 @@
 namespace Drupal\search\Plugin\views\filter;
 
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\search\ViewsSearchQuery;
 use Drupal\views\Plugin\views\filter\FilterPluginBase;
 use Drupal\views\Plugin\views\display\DisplayPluginBase;
 use Drupal\views\ViewExecutable;
@@ -119,7 +120,7 @@ public function validateExposed(&$form, FormStateInterface $form_state) {
   protected function queryParseSearchExpression($input) {
     if (!isset($this->searchQuery)) {
       $this->parsed = TRUE;
-      $this->searchQuery = \Drupal::service('database.replica')->select('search_index', 'i')->extend('views_search_query');
+      $this->searchQuery = \Drupal::service('database.replica')->select('search_index', 'i')->extend(ViewsSearchQuery::class);
       $this->searchQuery->searchExpression($input, $this->searchType);
       $this->searchQuery->publicParseSearchExpression();
     }
diff --git a/core/modules/search/src/SearchQuery.php b/core/modules/search/src/SearchQuery.php
index 793eed880ebf4ec089392d56efaa3fbfd807b173..6869da434f7128da7e6063deb2beb8d21319b2ff 100644
--- a/core/modules/search/src/SearchQuery.php
+++ b/core/modules/search/src/SearchQuery.php
@@ -2,8 +2,6 @@
 
 namespace Drupal\search;
 
-use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Database\Connection;
 use Drupal\Core\Database\Query\SelectExtender;
 use Drupal\Core\Database\Query\SelectInterface;
 
@@ -188,27 +186,6 @@ class SearchQuery extends SelectExtender {
    */
   protected $multiply = [];
 
-  /**
-   * Constructs a TableSortExtender object.
-   *
-   * @param \Drupal\Core\Database\Query\SelectInterface $query
-   *   Select query object.
-   * @param \Drupal\Core\Database\Connection $connection
-   *   Database connection object.
-   * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
-   *   The config factory.
-   * @param \Drupal\search\SearchTextProcessorInterface $searchTextProcessor
-   *   The search text processor service.
-   */
-  public function __construct(
-    SelectInterface $query,
-    Connection $connection,
-    protected ConfigFactoryInterface $configFactory,
-    protected SearchTextProcessorInterface $searchTextProcessor
-  ) {
-    parent::__construct($query, $connection);
-  }
-
   /**
    * Sets the search query expression.
    *
@@ -254,7 +231,9 @@ protected function parseSearchExpression() {
 
     // Classify tokens.
     $in_or = FALSE;
-    $limit_combinations = $this->configFactory->get('search.settings')->get('and_or_limit');
+    $limit_combinations = \Drupal::config('search.settings')->get('and_or_limit');
+    /** @var \Drupal\search\SearchTextProcessorInterface $text_processor */
+    $text_processor = \Drupal::service('search.text_processor');
     // The first search expression does not count as AND.
     $and_count = -1;
     $or_count = 0;
@@ -277,7 +256,7 @@ protected function parseSearchExpression() {
       // Simplify keyword according to indexing rules and external
       // preprocessors. Use same process as during search indexing, so it
       // will match search index.
-      $words = $this->searchTextProcessor->analyze($match[2]);
+      $words = $text_processor->analyze($match[2]);
       // Re-explode in case simplification added more words, except when
       // matching a phrase.
       $words = $phrase ? [$words] : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
@@ -385,7 +364,7 @@ protected function parseWord($word) {
     $split = explode(' ', $word);
     foreach ($split as $s) {
       $num = is_numeric($s);
-      if ($num || mb_strlen($s) >= $this->configFactory->get('search.settings')->get('index.minimum_word_size')) {
+      if ($num || mb_strlen($s) >= \Drupal::config('search.settings')->get('index.minimum_word_size')) {
         if (!isset($this->words[$s])) {
           $this->words[$s] = $s;
           $num_new_scores++;
diff --git a/core/modules/search/src/SearchQueryFactory.php b/core/modules/search/src/SearchQueryFactory.php
deleted file mode 100644
index c807d932f3b5e9577e0c7f68255f74a10f5e7e37..0000000000000000000000000000000000000000
--- a/core/modules/search/src/SearchQueryFactory.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-namespace Drupal\search;
-
-use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Database\Connection;
-use Drupal\Core\Database\Query\SelectInterface;
-
-/**
- * Select extender factory for search queries.
- */
-class SearchQueryFactory {
-
-  /**
-   * Constructs a SearchQueryFactory object.
-   *
-   * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
-   *   The config factory.
-   * @param \Drupal\search\SearchTextProcessorInterface $searchTextProcessor
-   *   The search text processor service.
-   */
-  public function __construct(
-    protected ConfigFactoryInterface $configFactory,
-    protected SearchTextProcessorInterface $searchTextProcessor
-  ) {
-  }
-
-  /**
-   * Returns a query extender for search queries.
-   *
-   * @param \Drupal\Core\Database\Query\SelectInterface $query
-   *   Select query object.
-   * @param \Drupal\Core\Database\Connection $connection
-   *   Database connection object.
-   *
-   * @return Drupal\search\SearchQuery
-   *   A query extender for search queries.
-   */
-  public function get(SelectInterface $query, Connection $connection): SearchQuery {
-    return new SearchQuery($query, $connection, $this->configFactory, $this->searchTextProcessor);
-  }
-
-}
diff --git a/core/modules/search/src/ViewsSearchQueryFactory.php b/core/modules/search/src/ViewsSearchQueryFactory.php
deleted file mode 100644
index 70beb8f61287c164ebfe441f524dd46dafd45d75..0000000000000000000000000000000000000000
--- a/core/modules/search/src/ViewsSearchQueryFactory.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-namespace Drupal\search;
-
-use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Database\Connection;
-use Drupal\Core\Database\Query\SelectInterface;
-
-/**
- * Select extender factory for views search queries.
- */
-class ViewsSearchQueryFactory {
-
-  /**
-   * Constructs a ViewsSearchQueryFactory object.
-   *
-   * @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
-   *   The config factory.
-   * @param \Drupal\search\SearchTextProcessorInterface $searchTextProcessor
-   *   The search text processor service.
-   */
-  public function __construct(
-    protected ConfigFactoryInterface $configFactory,
-    protected SearchTextProcessorInterface $searchTextProcessor
-  ) {
-  }
-
-  /**
-   * Returns a query extender for views search queries.
-   *
-   * @param \Drupal\Core\Database\Query\SelectInterface $query
-   *   Select query object.
-   * @param \Drupal\Core\Database\Connection $connection
-   *   Database connection object.
-   *
-   * @return Drupal\search\ViewsSearchQuery
-   *   A query extender for views search queries.
-   */
-  public function get(SelectInterface $query, Connection $connection): ViewsSearchQuery {
-    return new ViewsSearchQuery($query, $connection, $this->configFactory, $this->searchTextProcessor);
-  }
-
-}
diff --git a/core/modules/search/tests/src/Kernel/SearchMatchTest.php b/core/modules/search/tests/src/Kernel/SearchMatchTest.php
index 6915d7dc5360aabca00c7c0c472eccbbe93cf9f3..9ec5853f72002176c31663bd8a26bf24814653f2 100644
--- a/core/modules/search/tests/src/Kernel/SearchMatchTest.php
+++ b/core/modules/search/tests/src/Kernel/SearchMatchTest.php
@@ -6,6 +6,7 @@
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\KernelTests\KernelTestBase;
 use Drupal\search\SearchIndexInterface;
+use Drupal\search\SearchQuery;
 
 /**
  * Indexes content and queries it.
@@ -164,7 +165,7 @@ public function _testQueries() {
     $connection = Database::getConnection();
     foreach ($queries as $query => $results) {
       $result = $connection->select('search_index', 'i')
-        ->extend('search_query')
+        ->extend(SearchQuery::class)
         ->searchExpression($query, static::SEARCH_TYPE)
         ->execute();
 
@@ -184,7 +185,7 @@ public function _testQueries() {
     ];
     foreach ($queries as $query => $results) {
       $result = $connection->select('search_index', 'i')
-        ->extend('search_query')
+        ->extend(SearchQuery::class)
         ->searchExpression($query, static::SEARCH_TYPE_2)
         ->execute();
 
@@ -207,7 +208,7 @@ public function _testQueries() {
     ];
     foreach ($queries as $query => $results) {
       $result = $connection->select('search_index', 'i')
-        ->extend('search_query')
+        ->extend(SearchQuery::class)
         ->searchExpression($query, static::SEARCH_TYPE_JPN)
         ->execute();
 
diff --git a/core/modules/system/tests/modules/database_test/database_test.services.yml b/core/modules/system/tests/modules/database_test/database_test.services.yml
deleted file mode 100644
index 25ee69707aced1f9bf144adaa54ae4f9d0746c6a..0000000000000000000000000000000000000000
--- a/core/modules/system/tests/modules/database_test/database_test.services.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-services:
-  select_extender_factory.test_extender:
-    class: Drupal\database_test\TestExtenderFactory
-    tags:
-      - { name: backend_overridable }
diff --git a/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php b/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php
index 4f5bede810dede50d45183f81088504e73090e32..ddc5f7577b26529d90450587dfe2a65cdcbe2b42 100644
--- a/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php
+++ b/core/modules/system/tests/modules/database_test/src/Controller/DatabaseTestController.php
@@ -4,6 +4,8 @@
 
 use Drupal\Core\Controller\ControllerBase;
 use Drupal\Core\Database\Connection;
+use Drupal\Core\Database\Query\PagerSelectExtender;
+use Drupal\Core\Database\Query\TableSortExtender;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 use Symfony\Component\HttpFoundation\JsonResponse;
 
@@ -54,7 +56,7 @@ public function pagerQueryEven($limit) {
 
     // This should result in 2 pages of results.
     $query = $query
-      ->extend('pager')
+      ->extend(PagerSelectExtender::class)
       ->limit($limit);
 
     $names = $query->execute()->fetchCol();
@@ -80,7 +82,7 @@ public function pagerQueryOdd($limit) {
 
     // This should result in 4 pages of results.
     $query = $query
-      ->extend('pager')
+      ->extend(PagerSelectExtender::class)
       ->limit($limit);
 
     $names = $query->execute()->fetchCol();
@@ -111,7 +113,7 @@ public function testTablesort() {
       ->fields('t', ['tid', 'pid', 'task', 'priority']);
 
     $query = $query
-      ->extend('table_sort')
+      ->extend(TableSortExtender::class)
       ->orderByHeader($header);
 
     // We need all the results at once to check the sort.
@@ -143,7 +145,7 @@ public function testTablesortFirst() {
       ->fields('t', ['tid', 'pid', 'task', 'priority']);
 
     $query = $query
-      ->extend('table_sort')
+      ->extend(TableSortExtender::class)
       ->orderByHeader($header)
       ->orderBy('priority');
 
diff --git a/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php b/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php
index 07f538ad3a4ba509f234731adb96d118f24c6873..5570c96f5f687cdedfbf41c3798ccd8cdf98e1ec 100644
--- a/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php
+++ b/core/modules/system/tests/modules/database_test/src/Form/DatabaseTestForm.php
@@ -3,6 +3,8 @@
 namespace Drupal\database_test\Form;
 
 use Drupal\Core\Database\Database;
+use Drupal\Core\Database\Query\PagerSelectExtender;
+use Drupal\Core\Database\Query\TableSortExtender;
 use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\user\Entity\User;
@@ -38,8 +40,8 @@ public function buildForm(array $form, FormStateInterface $form_state) {
     $count_query->addExpression('COUNT([u].[uid])');
 
     $query = $query
-      ->extend('pager')
-      ->extend('table_sort');
+      ->extend(PagerSelectExtender::class)
+      ->extend(TableSortExtender::class);
     $query
       ->fields('u', ['uid'])
       ->limit(50)
diff --git a/core/modules/system/tests/modules/database_test/src/TestExtenderFactory.php b/core/modules/system/tests/modules/database_test/src/TestExtenderFactory.php
deleted file mode 100644
index d4624d14b88f5d4673191ebc9983dcc59606c058..0000000000000000000000000000000000000000
--- a/core/modules/system/tests/modules/database_test/src/TestExtenderFactory.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-namespace Drupal\database_test;
-
-use Drupal\Core\Database\Connection;
-use Drupal\Core\Database\Query\SelectExtender;
-use Drupal\Core\Database\Query\SelectInterface;
-
-/**
- * Test select extender factory.
- */
-class TestExtenderFactory {
-
-  /**
-   * Returns a test query extender.
-   *
-   * @param \Drupal\Core\Database\Query\SelectInterface $query
-   *   Select query object.
-   * @param \Drupal\Core\Database\Connection $connection
-   *   Database connection object.
-   *
-   * @return \Drupal\Core\Database\Query\SelectExtender
-   *   A test query extender.
-   */
-  public function get(SelectInterface $query, Connection $connection): SelectExtender {
-    return new SelectExtender($query, $connection);
-  }
-
-}
diff --git a/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php b/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php
index 7ed5dfa9e729e6ec9f6ff1e22d676d8ec4381508..2cdba660120311cc725e29af5541df4466829b76 100644
--- a/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php
+++ b/core/modules/system/tests/modules/pager_test/src/Controller/PagerTestController.php
@@ -4,6 +4,7 @@
 
 use Drupal\Core\Controller\ControllerBase;
 use Drupal\Core\Database\Database;
+use Drupal\Core\Database\Query\PagerSelectExtender;
 use Drupal\Core\Pager\PagerParametersInterface;
 use Drupal\Core\Security\TrustedCallbackInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -54,7 +55,7 @@ protected function buildTestTable($element, $limit) {
       ['data' => 'type'],
       ['data' => 'timestamp'],
     ];
-    $query = Database::getConnection()->select('watchdog', 'd')->extend('pager')->element($element);
+    $query = Database::getConnection()->select('watchdog', 'd')->extend(PagerSelectExtender::class)->element($element);
     $result = $query
       ->fields('d', ['wid', 'type', 'timestamp'])
       ->limit($limit)
diff --git a/core/modules/system/tests/src/Functional/Database/SelectPagerDefaultTest.php b/core/modules/system/tests/src/Functional/Database/SelectPagerDefaultTest.php
index ef7079bfdf7c8c8bc0e129add6d1df733df10893..41aa5c3a830994e61b1aa48cce236b5809149cdd 100644
--- a/core/modules/system/tests/src/Functional/Database/SelectPagerDefaultTest.php
+++ b/core/modules/system/tests/src/Functional/Database/SelectPagerDefaultTest.php
@@ -4,6 +4,7 @@
 
 use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Database\Database;
+use Drupal\Core\Database\Query\PagerSelectExtender;
 use Symfony\Component\HttpFoundation\Request;
 
 /**
@@ -94,7 +95,7 @@ public function testOddPagerQuery() {
   public function testInnerPagerQuery() {
     $connection = Database::getConnection();
     $query = $connection->select('test', 't')
-      ->extend('pager');
+      ->extend(PagerSelectExtender::class);
     $query
       ->fields('t', ['age'])
       ->orderBy('age')
@@ -117,7 +118,7 @@ public function testInnerPagerQuery() {
    */
   public function testHavingPagerQuery() {
     $query = Database::getConnection()->select('test', 't')
-      ->extend('pager');
+      ->extend(PagerSelectExtender::class);
     $query
       ->fields('t', ['name'])
       ->orderBy('name')
@@ -144,7 +145,7 @@ public function testElementNumbers() {
 
     $connection = Database::getConnection();
     $query = $connection->select('test', 't')
-      ->extend('pager')
+      ->extend(PagerSelectExtender::class)
       ->element(2)
       ->fields('t', ['name'])
       ->orderBy('age')
@@ -157,7 +158,7 @@ public function testElementNumbers() {
     // Setting an element smaller than the previous one should not collide with
     // the existing pager.
     $query = $connection->select('test', 't')
-      ->extend('pager')
+      ->extend(PagerSelectExtender::class)
       ->element(1)
       ->fields('t', ['name'])
       ->orderBy('age')
@@ -168,7 +169,7 @@ public function testElementNumbers() {
     $this->assertEquals('George', $name, 'Pager query #2 with a specified element ID returned the correct results.');
 
     $query = $connection->select('test', 't')
-      ->extend('pager')
+      ->extend(PagerSelectExtender::class)
       ->fields('t', ['name'])
       ->orderBy('age')
       ->limit(1);
diff --git a/core/modules/tracker/src/Controller/TrackerController.php b/core/modules/tracker/src/Controller/TrackerController.php
index 469f55a071e481279d8dd0358274ea80a47674b0..aeb65755ee4af039455edcc79df03daf06a83f31 100644
--- a/core/modules/tracker/src/Controller/TrackerController.php
+++ b/core/modules/tracker/src/Controller/TrackerController.php
@@ -7,6 +7,7 @@
 use Drupal\Core\Cache\CacheableMetadata;
 use Drupal\Core\Controller\ControllerBase;
 use Drupal\Core\Database\Connection;
+use Drupal\Core\Database\Query\PagerSelectExtender;
 use Drupal\Core\Datetime\DateFormatterInterface;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Session\AccountInterface;
@@ -130,13 +131,13 @@ public function checkAccess(UserInterface $user, AccountInterface $account) {
   public function buildContent(UserInterface $user = NULL) {
     if ($user) {
       $query = $this->database->select('tracker_user', 't')
-        ->extend('pager')
+        ->extend(PagerSelectExtender::class)
         ->addMetaData('base_table', 'tracker_user')
         ->condition('t.uid', $user->id());
     }
     else {
       $query = $this->databaseReplica->select('tracker_node', 't')
-        ->extend('pager')
+        ->extend(PagerSelectExtender::class)
         ->addMetaData('base_table', 'tracker_node');
     }
 
diff --git a/core/modules/user/src/Plugin/Search/UserSearch.php b/core/modules/user/src/Plugin/Search/UserSearch.php
index eabe843e774ef9ac1596c3d66c6fb717ecd20b73..28f5d0e833638eea605f13f4bc349ee54d9c0273 100644
--- a/core/modules/user/src/Plugin/Search/UserSearch.php
+++ b/core/modules/user/src/Plugin/Search/UserSearch.php
@@ -4,6 +4,7 @@
 
 use Drupal\Core\Access\AccessResult;
 use Drupal\Core\Database\Connection;
+use Drupal\Core\Database\Query\PagerSelectExtender;
 use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Session\AccountInterface;
@@ -119,7 +120,7 @@ public function execute() {
     // Run the query to find matching users.
     $query = $this->database
       ->select('users_field_data', 'users')
-      ->extend('pager');
+      ->extend(PagerSelectExtender::class);
     $query->fields('users', ['uid']);
     $query->condition('default_langcode', 1);
     if ($this->currentUser->hasPermission('administer users')) {
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php
index 8ea4610b13fe1a68f8fd56c83ccff01f89dedb2a..281f3d4d57c96d589cc05c3b3920f24e3df5acf3 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php
@@ -4,6 +4,7 @@
 
 use Drupal\Component\Render\FormattableMarkup;
 use Drupal\Core\Database\Database;
+use Drupal\Core\Database\Query\PagerSelectExtender;
 use Drupal\Core\Database\RowCountException;
 use Drupal\user\Entity\User;
 
@@ -210,7 +211,7 @@ public function testCountQuery() {
    */
   public function testHavingCountQuery() {
     $query = $this->connection->select('test')
-      ->extend('pager')
+      ->extend(PagerSelectExtender::class)
       ->groupBy('age')
       ->having('[age] + 1 > 0');
     $query->addField('test', 'age');
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectExtenderTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectExtenderTest.php
index 3c9c49d41ad1e7ee73d0122f5dffb1ad37b00a07..5a23f9a2500ac3b17e68aad479fb6ecbd94bc77b 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SelectExtenderTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SelectExtenderTest.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\KernelTests\Core\Database;
 
+use Composer\Autoload\ClassLoader;
 use Drupal\Core\Database\Query\SelectExtender;
 use Drupal\KernelTests\KernelTestBase;
 use Drupal\Tests\Core\Database\Stub\StubConnection;
@@ -15,11 +16,6 @@
  */
 class SelectExtenderTest extends KernelTestBase {
 
-  /**
-   * {@inheritdoc}
-   */
-  protected static $modules = ['database_test', 'search'];
-
   /**
    * Data provider for testExtend().
    *
@@ -27,29 +23,89 @@ class SelectExtenderTest extends KernelTestBase {
    *   Array of arrays with the following elements:
    *   - Expected namespaced class name.
    *   - The database driver namespace.
-   *   - The suffix of the select_extender_factory.[suffix] service.
+   *   - The namespaced class name for which to extend.
    */
   public function providerExtend(): array {
     return [
       [
         'Drupal\Core\Database\Query\PagerSelectExtender',
         'Drupal\corefake\Driver\Database\corefake',
-        'pager',
+        'Drupal\Core\Database\Query\PagerSelectExtender',
+      ],
+      [
+        'Drupal\Core\Database\Query\PagerSelectExtender',
+        'Drupal\corefake\Driver\Database\corefake',
+        '\Drupal\Core\Database\Query\PagerSelectExtender',
+      ],
+      [
+        'Drupal\Core\Database\Query\TableSortExtender',
+        'Drupal\corefake\Driver\Database\corefake',
+        'Drupal\Core\Database\Query\TableSortExtender',
       ],
       [
         'Drupal\Core\Database\Query\TableSortExtender',
         'Drupal\corefake\Driver\Database\corefake',
-        'table_sort',
+        '\Drupal\Core\Database\Query\TableSortExtender',
       ],
       [
         'Drupal\search\SearchQuery',
         'Drupal\corefake\Driver\Database\corefake',
-        'search_query',
+        'Drupal\search\SearchQuery',
+      ],
+      [
+        'Drupal\search\SearchQuery',
+        'Drupal\corefake\Driver\Database\corefake',
+        '\Drupal\search\SearchQuery',
+      ],
+      [
+        'Drupal\search\ViewsSearchQuery',
+        'Drupal\corefake\Driver\Database\corefake',
+        'Drupal\search\ViewsSearchQuery',
       ],
       [
         'Drupal\search\ViewsSearchQuery',
         'Drupal\corefake\Driver\Database\corefake',
-        'views_search_query',
+        '\Drupal\search\ViewsSearchQuery',
+      ],
+      [
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses\PagerSelectExtender',
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses',
+        'Drupal\Core\Database\Query\PagerSelectExtender',
+      ],
+      [
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses\PagerSelectExtender',
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses',
+        '\Drupal\Core\Database\Query\PagerSelectExtender',
+      ],
+      [
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses\TableSortExtender',
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses',
+        'Drupal\Core\Database\Query\TableSortExtender',
+      ],
+      [
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses\TableSortExtender',
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses',
+        '\Drupal\Core\Database\Query\TableSortExtender',
+      ],
+      [
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses\SearchQuery',
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses',
+        'Drupal\search\SearchQuery',
+      ],
+      [
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses\SearchQuery',
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses',
+        '\Drupal\search\SearchQuery',
+      ],
+      [
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses\ViewsSearchQuery',
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses',
+        'Drupal\search\ViewsSearchQuery',
+      ],
+      [
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses\ViewsSearchQuery',
+        'Drupal\corefake\Driver\Database\corefakeWithAllCustomClasses',
+        '\Drupal\search\ViewsSearchQuery',
       ],
     ];
   }
@@ -60,20 +116,25 @@ public function providerExtend(): array {
    * @dataProvider providerExtend
    */
   public function testExtend(string $expected, string $namespace, string $extend): void {
+    $additional_class_loader = new ClassLoader();
+    $additional_class_loader->addPsr4("Drupal\\corefake\\Driver\\Database\\corefake\\", __DIR__ . "/../../../../../tests/fixtures/database_drivers/module/corefake/src/Driver/Database/corefake");
+    $additional_class_loader->addPsr4("Drupal\\corefake\\Driver\\Database\\corefakeWithAllCustomClasses\\", __DIR__ . "/../../../../../tests/fixtures/database_drivers/module/corefake/src/Driver/Database/corefakeWithAllCustomClasses");
+    $additional_class_loader->register(TRUE);
+
     $mock_pdo = $this->createMock(StubPDO::class);
     $connection = new StubConnection($mock_pdo, ['namespace' => $namespace]);
 
     // Tests the method \Drupal\Core\Database\Query\Select::extend().
     $select = $connection->select('test')->extend($extend);
-    $this->assertInstanceOf($expected, $select);
+    $this->assertEquals($expected, get_class($select));
 
     // Get an instance of the class \Drupal\Core\Database\Query\SelectExtender.
-    $select_extender = $connection->select('test')->extend('test_extender');
-    $this->assertInstanceOf(SelectExtender::class, $select_extender);
+    $select_extender = $connection->select('test')->extend(SelectExtender::class);
+    $this->assertEquals(SelectExtender::class, get_class($select_extender));
 
     // Tests the method \Drupal\Core\Database\Query\SelectExtender::extend().
     $select_extender_extended = $select_extender->extend($extend);
-    $this->assertInstanceOf($expected, $select_extender_extended);
+    $this->assertEquals($expected, get_class($select_extender_extended));
   }
 
 }
diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
index 3301f5b7133b8c1033c6fb767c280308776427b6..fe85345d9b9419206dd41853d4042e37c8c03637 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php
@@ -5,6 +5,7 @@
 use Drupal\Core\Database\InvalidQueryException;
 use Drupal\Core\Database\Database;
 use Drupal\Core\Database\DatabaseExceptionWrapper;
+use Drupal\Core\Database\Query\SelectExtender;
 
 /**
  * Tests the Select query builder.
@@ -280,7 +281,7 @@ public function testAlwaysFalseCondition() {
    */
   public function testExtenderAlwaysFalseCondition() {
     $names = $this->connection->select('test', 'test')
-      ->extend('test_extender')
+      ->extend(SelectExtender::class)
       ->fields('test', ['name'])
       ->condition('age', 27)
       ->execute()->fetchCol();
@@ -289,7 +290,7 @@ public function testExtenderAlwaysFalseCondition() {
     $this->assertSame($names[0], 'George');
 
     $names = $this->connection->select('test', 'test')
-      ->extend('test_extender')
+      ->extend(SelectExtender::class)
       ->fields('test', ['name'])
       ->condition('age', 27)
       ->alwaysFalse()
diff --git a/core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php b/core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php
index 51b0e1a1eeccc320e17afda1f0b975cdb203f223..3a9ea2c7e6e0505f50cc3b9885ec70ee073e12e1 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\KernelTests\Core\Database;
 
+use Drupal\Core\Database\Query\SelectExtender;
+
 /**
  * Tests the tagging capabilities of the Select builder.
  *
@@ -60,7 +62,7 @@ public function testHasAnyTag() {
    */
   public function testExtenderHasTag() {
     $query = $this->connection->select('test')
-      ->extend('test_extender');
+      ->extend(SelectExtender::class);
     $query->addField('test', 'name');
     $query->addField('test', 'age', 'age');
 
@@ -75,7 +77,7 @@ public function testExtenderHasTag() {
    */
   public function testExtenderHasAllTags() {
     $query = $this->connection->select('test')
-      ->extend('test_extender');
+      ->extend(SelectExtender::class);
     $query->addField('test', 'name');
     $query->addField('test', 'age', 'age');
 
@@ -91,7 +93,7 @@ public function testExtenderHasAllTags() {
    */
   public function testExtenderHasAnyTag() {
     $query = $this->connection->select('test')
-      ->extend('test_extender');
+      ->extend(SelectExtender::class);
     $query->addField('test', 'name');
     $query->addField('test', 'age', 'age');