From 3097abfab6e1cb2e22e9acf9145a8394c2d19123 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 24 Jan 2026 15:06:59 +0100 Subject: MariaDB restrict USE INDEX (#8460) fix https://github.com/FreshRSS/FreshRSS/issues/8455 Follow-up of https://github.com/FreshRSS/FreshRSS/pull/8211 --- app/Models/EntryDAO.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 6017fb413..d247b84b7 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -1454,7 +1454,10 @@ SQL; sort: $sort, order: $order, continuation_id: $continuation_id, continuation_values: $continuation_values); // Help MySQL/MariaDB's optimizer with the query plan: - $useEntryIndex = $this->pdo->dbType() === 'mysql' ? 'USE INDEX (entry_feed_read_index) ' : ''; + $useEntryIndex = ($this->pdo->dbType() === 'mysql' && // Only relevant for MySQL/MariaDB, + in_array($type, ['a', 'A', 'Z', 'i', 's', 'f'], true) && // for some of the queries using the feed table, + preg_match('/is_read\\s*=\\s*[01]\\b/', $search)) // where is_read is a criteria + ? 'USE INDEX (entry_feed_read_index) ' : ''; return [array_merge($values, $searchValues), 'SELECT ' . ($type === 'T' ? 'DISTINCT ' : '') -- cgit v1.2.3