aboutsummaryrefslogtreecommitdiff
path: root/app/Models/EntryDAO.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2026-01-24 15:06:59 +0100
committerGravatar GitHub <noreply@github.com> 2026-01-24 15:06:59 +0100
commit3097abfab6e1cb2e22e9acf9145a8394c2d19123 (patch)
tree01c9d500a4380b775964fccb91b803c05ff2106c /app/Models/EntryDAO.php
parentbb579956cb38258b1264adaba94e53e14b2b1004 (diff)
MariaDB restrict USE INDEX (#8460)
fix https://github.com/FreshRSS/FreshRSS/issues/8455 Follow-up of https://github.com/FreshRSS/FreshRSS/pull/8211
Diffstat (limited to 'app/Models/EntryDAO.php')
-rw-r--r--app/Models/EntryDAO.php5
1 files changed, 4 insertions, 1 deletions
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 ' : '')