From 393e563190f526cfbf3e9914333dceebf07892c3 Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Wed, 10 Jan 2024 11:22:11 +0200 Subject: [PATCH] PDO: Use index hint for source_update_needed only if a source filter is specified. --- src/RecordManager/Base/Database/PDODatabase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RecordManager/Base/Database/PDODatabase.php b/src/RecordManager/Base/Database/PDODatabase.php index 3c16b5e0..b24ca522 100644 --- a/src/RecordManager/Base/Database/PDODatabase.php +++ b/src/RecordManager/Base/Database/PDODatabase.php @@ -1261,7 +1261,7 @@ protected function getIndexHints(string $collection, array $filter, array $optio if (!$this->useIndexHints || !$this->isMySQLCompatible()) { return ''; } - if ('record' === $collection && isset($options['sort']['_id'])) { + if ('record' === $collection && isset($options['sort']['_id']) && isset($filter['source_id'])) { return 'USE INDEX (source_update_needed)'; } return '';