aboutsummaryrefslogtreecommitdiff
path: root/app/Models/FeedDAO.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2025-11-15 20:11:25 +0100
committerGravatar GitHub <noreply@github.com> 2025-11-15 20:11:25 +0100
commit45471871ddc4bae6c1c36f2daa9091b85e458e8c (patch)
treea67c1c0b9073ed457764cb1b1b831d099acdb42f /app/Models/FeedDAO.php
parentea8938b0d14ea1373ab3757494d0c0c1ef0e843e (diff)
SQL: Optimise speed of updateCachedValues() (#8207)
For PostgreSQL and SQLite fix https://github.com/FreshRSS/FreshRSS/issues/8206
Diffstat (limited to 'app/Models/FeedDAO.php')
-rw-r--r--app/Models/FeedDAO.php8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php
index 2e0d5781a..0353f9a05 100644
--- a/app/Models/FeedDAO.php
+++ b/app/Models/FeedDAO.php
@@ -481,10 +481,10 @@ SQL;
public function updateCachedValues(int ...$feedIds): int|false {
//2 sub-requests with FOREIGN KEY(e.id_feed), INDEX(e.is_read) faster than 1 request with GROUP BY or CASE
$sql = <<<SQL
-UPDATE `_feed`
-SET `cache_nbEntries`=(SELECT COUNT(e1.id) FROM `_entry` e1 WHERE e1.id_feed=`_feed`.id),
- `cache_nbUnreads`=(SELECT COUNT(e2.id) FROM `_entry` e2 WHERE e2.id_feed=`_feed`.id AND e2.is_read=0)
-SQL;
+ UPDATE `_feed`
+ SET `cache_nbEntries`=(SELECT COUNT(e1.id) FROM `_entry` e1 WHERE e1.id_feed=`_feed`.id),
+ `cache_nbUnreads`=(SELECT COUNT(e2.id) FROM `_entry` e2 WHERE e2.id_feed=`_feed`.id AND e2.is_read=0)
+ SQL;
if (count($feedIds) > 0) {
$sql .= ' WHERE id IN (' . str_repeat('?,', count($feedIds) - 1) . '?)';
}