diff --git a/core/modules/system/tests/modules/performance_test/src/DatabaseEventEnabler.php b/core/modules/system/tests/modules/performance_test/src/DatabaseEventEnabler.php
index ec75884fd9720a7f1584a9ff4a35c6a342a17918..d9bce6142a2df975f12fd148e7ade213ba8aca72 100644
--- a/core/modules/system/tests/modules/performance_test/src/DatabaseEventEnabler.php
+++ b/core/modules/system/tests/modules/performance_test/src/DatabaseEventEnabler.php
@@ -3,11 +3,10 @@
 namespace Drupal\performance_test;
 
 use Drupal\Core\Database\Connection;
+use Drupal\Core\Database\Event\StatementEvent;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpFoundation\Response;
-use Drupal\Core\Database\Event\StatementExecutionEndEvent;
-use Drupal\Core\Database\Event\StatementExecutionStartEvent;
 
 class DatabaseEventEnabler implements HttpKernelInterface {
 
@@ -18,13 +17,7 @@ public function __construct(protected readonly HttpKernelInterface $httpKernel,
    */
   public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE): Response {
     if ($type === static::MAIN_REQUEST) {
-      $this->connection->enableEvents([
-        // StatementExecutionStartEvent must be enabled in order for
-        // StatementExecutionEndEvent to be fired, even though we only subscribe
-        // to the latter event.
-        StatementExecutionStartEvent::class,
-        StatementExecutionEndEvent::class,
-      ]);
+      $this->connection->enableEvents(StatementEvent::all());
     }
     return $this->httpKernel->handle($request, $type, $catch);
   }
diff --git a/core/modules/system/tests/modules/performance_test/src/PerformanceDataCollector.php b/core/modules/system/tests/modules/performance_test/src/PerformanceDataCollector.php
index b1176e2aefd7886c5820c482eb70670a75d6bdc9..e196d1ad926ede27ccbe331415d138144d2a354c 100644
--- a/core/modules/system/tests/modules/performance_test/src/PerformanceDataCollector.php
+++ b/core/modules/system/tests/modules/performance_test/src/PerformanceDataCollector.php
@@ -2,7 +2,9 @@
 
 namespace Drupal\performance_test;
 
+use Drupal\Core\Database\Event\DatabaseEvent;
 use Drupal\Core\Database\Event\StatementExecutionEndEvent;
+use Drupal\Core\Database\Event\StatementExecutionFailureEvent;
 use Drupal\Core\DestructableInterface;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 
@@ -11,7 +13,7 @@ class PerformanceDataCollector implements EventSubscriberInterface, Destructable
   /**
    * Database events collected during the request.
    *
-   * @var Drupal\Core\Database\Event\StatementExecutionEndEvent[]
+   * @var \Drupal\Core\Database\Event\DatabaseEvent[]
    */
   protected array $databaseEvents = [];
 
@@ -30,14 +32,15 @@ class PerformanceDataCollector implements EventSubscriberInterface, Destructable
    */
   public static function getSubscribedEvents(): array {
     return [
-      StatementExecutionEndEvent::class => 'onStatementExecutionEnd',
+      StatementExecutionEndEvent::class => 'onDatabaseEvent',
+      StatementExecutionFailureEvent::class => 'onDatabaseEvent',
     ];
   }
 
   /**
    * Logs database statements.
    */
-  public function onStatementExecutionEnd(StatementExecutionEndEvent $event): void {
+  public function onDatabaseEvent(DatabaseEvent $event): void {
     // Use the event object as a value object.
     $this->databaseEvents[] = $event;
   }
diff --git a/core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php b/core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php
index 19f0724d7fc7157376cd4f2b2fe77caf5d27e104..371ed6ed600049f4d815618258fc0c9046b06885 100644
--- a/core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php
+++ b/core/profiles/standard/tests/src/FunctionalJavascript/StandardPerformanceTest.php
@@ -202,6 +202,7 @@ public function testLogin(): void {
     }, 'standardLogin');
 
     $expected_queries = [
+      'SELECT "name", "value" FROM "key_value_expire" WHERE "expire" > "NOW" AND "name" IN ( "KEY" ) AND "collection" = "form"',
       'SELECT COUNT(*) AS "expression" FROM (SELECT 1 AS "expression" FROM "flood" "f" WHERE ("event" = "user.failed_login_ip") AND ("identifier" = "CLIENT_IP") AND ("timestamp" > "TIMESTAMP")) "subquery"',
       'SELECT "base_table"."uid" AS "uid", "base_table"."uid" AS "base_table_uid" FROM "users" "base_table" INNER JOIN "users_field_data" "users_field_data" ON "users_field_data"."uid" = "base_table"."uid" WHERE ("users_field_data"."name" IN ("ACCOUNT_NAME")) AND ("users_field_data"."default_langcode" IN (1))',
       'SELECT COUNT(*) AS "expression" FROM (SELECT 1 AS "expression" FROM "flood" "f" WHERE ("event" = "user.failed_login_user") AND ("identifier" = "CLIENT_IP") AND ("timestamp" > "TIMESTAMP")) "subquery"',
@@ -220,7 +221,7 @@ public function testLogin(): void {
     ];
     $recorded_queries = $performance_data->getQueries();
     $this->assertSame($expected_queries, $recorded_queries);
-    $this->assertSame(15, $performance_data->getQueryCount());
+    $this->assertSame(16, $performance_data->getQueryCount());
     $this->assertSame(60, $performance_data->getCacheGetCount());
     $this->assertSame(1, $performance_data->getCacheSetCount());
     $this->assertSame(1, $performance_data->getCacheDeleteCount());
@@ -256,6 +257,7 @@ public function testLoginBlock(): void {
     $expected_queries = [
       'SELECT "name", "value" FROM "key_value" WHERE "name" IN ( "theme:stark" ) AND "collection" = "config.entity.key_store.block"',
       'SELECT "config"."name" AS "name" FROM "config" "config" WHERE ("collection" = "") AND ("name" LIKE "search.page.%" ESCAPE ' . "'\\\\'" . ') ORDER BY "collection" ASC, "name" ASC',
+      'SELECT "name", "value" FROM "key_value_expire" WHERE "expire" > "NOW" AND "name" IN ( "KEY" ) AND "collection" = "form"',
       'SELECT COUNT(*) AS "expression" FROM (SELECT 1 AS "expression" FROM "flood" "f" WHERE ("event" = "user.failed_login_ip") AND ("identifier" = "CLIENT_IP") AND ("timestamp" > "TIMESTAMP")) "subquery"',
       'SELECT "base_table"."uid" AS "uid", "base_table"."uid" AS "base_table_uid" FROM "users" "base_table" INNER JOIN "users_field_data" "users_field_data" ON "users_field_data"."uid" = "base_table"."uid" WHERE ("users_field_data"."name" IN ("ACCOUNT_NAME")) AND ("users_field_data"."default_langcode" IN (1))',
       'SELECT "base"."uid" AS "uid", "base"."uuid" AS "uuid", "base"."langcode" AS "langcode" FROM "users" "base" WHERE "base"."uid" IN (2)',
@@ -274,7 +276,7 @@ public function testLoginBlock(): void {
     ];
     $recorded_queries = $performance_data->getQueries();
     $this->assertSame($expected_queries, $recorded_queries);
-    $this->assertSame(17, $performance_data->getQueryCount());
+    $this->assertSame(18, $performance_data->getQueryCount());
     $this->assertSame(107, $performance_data->getCacheGetCount());
     $this->assertSame(1, $performance_data->getCacheSetCount());
     $this->assertSame(1, $performance_data->getCacheDeleteCount());
diff --git a/core/tests/Drupal/Tests/PerformanceTestTrait.php b/core/tests/Drupal/Tests/PerformanceTestTrait.php
index 48cb4f15e258da35475f95a55d38d5689b2bbf05..9dd570827669484c6eb71e455dbc648dd375954a 100644
--- a/core/tests/Drupal/Tests/PerformanceTestTrait.php
+++ b/core/tests/Drupal/Tests/PerformanceTestTrait.php
@@ -243,6 +243,10 @@ protected static function logQuery(PerformanceData $performance_data, string $qu
         $args[':db_condition_placeholder_1'] = 'CSS_FILE';
       }
     }
+    elseif (str_starts_with($query, 'SELECT "name", "value" FROM "key_value_expire" WHERE "expire" >')) {
+      $args[':now'] = 'NOW';
+      $args[':keys__0'] = 'KEY';
+    }
 
     // Inline query arguments and log the query.
     $query = str_replace(array_keys($args), array_values(static::quoteQueryArgs($args)), $query);