Skip to content

SQLite, PostgreSQL: batch markRead for lists of IDs - #9575

Merged
Alkarex merged 3 commits into
FreshRSS:edgefrom
quinnypig:9574-batch-markread-sqlite-pgsql
Nov 17, 2026
Merged

Alkarex merged 3 commits into
FreshRSS:edgefrom
quinnypig:9574-batch-markread-sqlite-pgsql

Conversation

@quinnypig

Copy link
Copy Markdown
Contributor

Closes #9574

Changes proposed in this pull request:

  • FreshRSS_EntryDAOSQLite::markRead() now passes arrays of IDs to FreshRSS_EntryDAO::markRead(). That method already does a batched UPDATE … WHERE is_read<>? AND id IN (…), split into chunks by MAX_VARIABLE_NUMBER (998, which also covers SQLite's parameter limit), then refreshes the unread caches once. For lists of fewer than 6 IDs it still calls back into the existing per-entry SQLite/PostgreSQL path. FreshRSS_EntryDAOPGSQL inherits the change.
  • The @param type now matches the parent's list<numeric-string> (PHPStan argument.type).

How to test the feature manually:

  1. Use PostgreSQL with some latency (tc qdisc add dev eth0 root netem delay 25ms on the database host gave about 75 ms per round trip).
  2. Mark several hundred unread articles read in a single Google Reader API edit-tag request, or call FreshRSS_Factory::createEntryDao()->markRead($ids, true) from a CLI script.
  3. Compare elapsed time and check that SUM(cache_nbUnreads) still equals the unread count in _entry.

My results (official edge image; the DAO files are identical in 1.30.4):

Backend Case Before After
PostgreSQL 17, ~75 ms RTT mark 300 read 60.5 s 0.16 s
PostgreSQL 17, ~75 ms RTT resend the same 300 (no change) 37.6 s 0.08 s
PostgreSQL 17, ~75 ms RTT mark 2,500 read / unread (chunked) not run 0.49 s / 0.49 s
SQLite mark 300 read 1.48 s 0.01 s
SQLite mark 2,500 read / unread (chunked) not run 0.04 s / 0.04 s

Unread caches matched the entry table in every case, including lists under 6 IDs and mark-unread. A production instance (PostgreSQL about 100 ms away) has been running the PostgreSQL variant of this change. Reeder on iOS, which had been timing out on every sync, now syncs normally, and edit-tag requests finish in under a second.

Pull request checklist:

  • clear commit messages
  • code manually tested
  • unit tests written (optional if too hard): existing suites only; the batched path is the existing MySQL one
  • documentation updated: not applicable

Checks run in the freshrss/freshrss:edge image: PHPUnit (879 tests, 1 skipped for missing PostgreSQL DSN), PHPStan (phpstan.dist.neon, no errors), PHPCS, php -l. phpstan-next reports the same 407 errors as unpatched edge, none in this file.

🤖 Generated with Claude Code

FreshRSS_EntryDAOSQLite::markRead() handled an array of IDs one entry
per transaction, and FreshRSS_EntryDAOPGSQL inherits it. Delegate
arrays to FreshRSS_EntryDAO::markRead(), whose batched
UPDATE ... WHERE is_read<>? AND id IN (...) is portable, is chunked by
MAX_VARIABLE_NUMBER, and calls back into the per-entry path for small
lists.

Fix FreshRSS#9574

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Alkarex Alkarex added this to the 1.31.0 milestone Nov 17, 2026
@Alkarex

Alkarex commented Nov 17, 2026

Copy link
Copy Markdown
Member

Thanks!

@Alkarex
Alkarex merged commit d6c907b into FreshRSS:edge Nov 17, 2026
4 checks passed
@Alkarex Alkarex added the API 🤝 API for other clients label Nov 17, 2026
GiorgioAresu pushed a commit to GiorgioAresu/home-ops that referenced this pull request Nov 30, 2026
…735)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [freshrss/freshrss](https://freshrss.org/) ([source](https://github.com/FreshRSS/FreshRSS)) | minor | `1.30.4-alpine` → `1.31.0-alpine` |

---

### Release Notes

<details>
<summary>FreshRSS/FreshRSS (freshrss/freshrss)</summary>

### [`v1.31.0`](https://github.com/FreshRSS/FreshRSS/blob/HEAD/CHANGELOG.md#2026-11-23-FreshRSS-1310)

[Compare Source](FreshRSS/FreshRSS@1.30.4...1.31.0)

- Compatibility
  - 💥 Require PHP 8.2+ (drop PHP 8.1) [#&#8203;9470](FreshRSS/FreshRSS#9470), [GHSA-66ff-8p23-wx95](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-66ff-8p23-wx95)
    - And recommend PHP 8.4+ for native HTML5 parsing (compliance, security, performance)
- Features
  - Use PHP 8.4+ `\Dom` classes and functions when available (polyfill for PHP < 8.4) [#&#8203;9567](FreshRSS/FreshRSS#9567)
    - Polyfill `GT\CssXPath`: Add support for case insensitivity [phpgt/CssXPath#256](phpgt/CssXPath#256)
  - Use native HTML5 `<img loading="lazy"` instead of custom JavaScript [#&#8203;5816](FreshRSS/FreshRSS#5816), [#&#8203;9601](FreshRSS/FreshRSS#9601), [GHSA-fc53-pf4q-9phm](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-fc53-pf4q-9phm)
  - User queries can define their own sorting criterion (field and direction) [#&#8203;8954](FreshRSS/FreshRSS#8954)
  - Better catch and log user regex errors [#&#8203;9559](FreshRSS/FreshRSS#9559)
  - Sharing by RSS emit `<enclosure>` for BitTorrent attachments [#&#8203;9553](FreshRSS/FreshRSS#9553)
  - Add filter preview button to label configuration [#&#8203;9538](FreshRSS/FreshRSS#9538)
- Bug fixes
  - Fix HTTP Retry-After cache when proxy is used [#&#8203;9508](FreshRSS/FreshRSS#9508)
  - Fix 32-bit systems provide a string for SQL BIGINT [#&#8203;9486](FreshRSS/FreshRSS#9486)
  - Fix tests for 32-bit systems [#&#8203;9578](FreshRSS/FreshRSS#9578)
  - Fix API lookup of the localised default category [#&#8203;9543](FreshRSS/FreshRSS#9543)
  - Keep JSON feed attachments as enclosures [#&#8203;9510](FreshRSS/FreshRSS#9510)
  - Fix: do not double-encode titles and authors when importing JSON [#&#8203;9556](FreshRSS/FreshRSS#9556)
  - Fix OPML import of numeric-string category names [#&#8203;9552](FreshRSS/FreshRSS#9552)
  - Fix saved search references with overlapping IDs or names [#&#8203;9484](FreshRSS/FreshRSS#9484), [#&#8203;9524](FreshRSS/FreshRSS#9524)
  - Fix shared queries: keep user search in HTML pagination [#&#8203;9545](FreshRSS/FreshRSS#9545)
  - Fix non-ASCII characters in scripts of fetched HTML pages [#&#8203;9384](FreshRSS/FreshRSS#9384)
  - PostgreSQL: detect FreshRSS tables by visibility rather than owner [#&#8203;9535](FreshRSS/FreshRSS#9535)
  - Fix UI: Load theme icons in views rendered without layout [#&#8203;9564](FreshRSS/FreshRSS#9564)
  - GReader API: compare `Authorization:GoogleLogin` and other headers case insensitive [#&#8203;9534](FreshRSS/FreshRSS#9534)
  - Return false when the configuration file cannot be replaced [#&#8203;9580](FreshRSS/FreshRSS#9580)
  - Fix technical details in documentation system [#&#8203;9520](FreshRSS/FreshRSS#9520), [#&#8203;9521](FreshRSS/FreshRSS#9521)
- Security
  - 💥 Replace bcrypt challenge auth with direct password comparison [#&#8203;9358](FreshRSS/FreshRSS#9358), [#&#8203;9550](FreshRSS/FreshRSS#9550), [#&#8203;9566](FreshRSS/FreshRSS#9566), [GHSA-8pvw-w7w8-vjj7](GHSA-8pvw-w7w8-vjj7), [GHSA-5vxm-62pg-frff](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-5vxm-62pg-frff)
  - Search: quote parentheses and `OR` when serialising terms [#&#8203;9541](FreshRSS/FreshRSS#9541)
  - Use HTTP header `Cross-Origin-Opener-Policy: same-origin` [#&#8203;9588](FreshRSS/FreshRSS#9588), [GHSA-75f7-8cvm-v87v](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-75f7-8cvm-v87v), [GHSA-gpvq-chwv-g674](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-gpvq-chwv-g674)
  - WebSub security: Implement support for `hub.secret` [#&#8203;9430](FreshRSS/FreshRSS#9430), [GHSA-498g-vgpq-mr66](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-498g-vgpq-mr66)
  - Reduce risk of data cache leak [#&#8203;9591](FreshRSS/FreshRSS#9591), [GHSA-4r8m-g5px-6pg7](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-4r8m-g5px-6pg7), [GHSA-fhcq-gjx8-fg9g](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-fhcq-gjx8-fg9g)
  - Fix leak of feed credentials to anonymous readers [#&#8203;9591](FreshRSS/FreshRSS#9591), [GHSA-fr4r-3w2g-rqf5](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-fr4r-3w2g-rqf5)
  - Sanitize Punycode [#&#8203;9591](FreshRSS/FreshRSS#9591), [GHSA-qv45-78vh-92w4](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-qv45-78vh-92w4)
  - Validate domain in SSRF check [#&#8203;9611](FreshRSS/FreshRSS#9611), [GHSA-3ch8-46c3-xr9h](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-3ch8-46c3-xr9h)
  - Fix search references [#&#8203;9591](FreshRSS/FreshRSS#9591), [GHSA-qwpx-vccf-m8xf](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-qwpx-vccf-m8xf)
  - Prevent use of irrelevant parameter in shared user queries [#&#8203;9589](FreshRSS/FreshRSS#9589), [GHSA-9v4j-jqr6-4cvv](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-9v4j-jqr6-4cvv)
  - Fix user enumeration by probing inconsistent error responses on failed logins [#&#8203;9568](FreshRSS/FreshRSS#9568)
  - Safer login [#&#8203;9592](FreshRSS/FreshRSS#9592), [#&#8203;9598](FreshRSS/FreshRSS#9598), [GHSA-rqqp-9h9w-h9m5](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-rqqp-9h9w-h9m5)
  - More secure remove access [#&#8203;9610](FreshRSS/FreshRSS#9610), [GHSA-r27w-hr3c-hjr3](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-r27w-hr3c-hjr3)
  - Better sanitize bookmark [#&#8203;9594](FreshRSS/FreshRSS#9594), [GHSA-jc2v-8853-5jqf](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-jc2v-8853-5jqf)
  - Fix escape labels during JSON import and render tag dropdown as text [#&#8203;9504](FreshRSS/FreshRSS#9504), [GHSA-4vcq-4q92-v45q](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-4vcq-4q92-v45q)
  - More security for extension files: `X-Content-Type-Options: nosniff` [#&#8203;9593](FreshRSS/FreshRSS#9593), [GHSA-w38f-92pp-95hg](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-w38f-92pp-95hg)
  - Fix HTML injection in view mode error notification [#&#8203;9605](FreshRSS/FreshRSS#9605), [GHSA-wpf6-5v7v-6cvj](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-wpf6-5v7v-6cvj)
  - Fix HTML injection in extension names [#&#8203;9608](FreshRSS/FreshRSS#9608), [GHSA-crc7-3qcq-m9h3](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-crc7-3qcq-m9h3)
  - Fix full-content logic [#&#8203;9602](FreshRSS/FreshRSS#9602), [GHSA-5hcv-wqwr-j8r8](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-5hcv-wqwr-j8r8)
  - Sanitize DB install params [#&#8203;9595](FreshRSS/FreshRSS#9595), [GHSA-xm97-f66c-q5fx](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-xm97-f66c-q5fx)
  - Document threat model for security scanners [#&#8203;9509](FreshRSS/FreshRSS#9509)
    - Enrolled in Anthropic OSS Scanner service that scans critical open-source repositories for security vulnerabilities [anthropics/oss-scanner#1434](anthropics/oss-scanner#1434)
  - Use a keyed hash for favicon cache keys [#&#8203;9518](FreshRSS/FreshRSS#9518), [GHSA-jqm2-jqjv-m87h](https://github.com/FreshRSS/FreshRSS/security/advisories/GHSA-jqm2-jqjv-m87h)
- Performance
  - SQL speed improvement for batch mark as read under SQLite and PostgreSQL [#&#8203;9575](FreshRSS/FreshRSS#9575)
- SimplePie
  - Use PHP 8.4+ `\Dom` classes and functions when available (polyfill for PHP < 8.4) [FreshRSS/simplepie#98](FreshRSS/simplepie#98)
    - Upgrade to PHPStan 2 [FreshRSS/simplepie#97](FreshRSS/simplepie#97), [simplepie#939](simplepie/simplepie#939)
    - Add unit test for HTML5 sanitizing compliance [simplepie#1022](simplepie/simplepie#1022)
    - Remove obsolete `xml_is_sane` and `XMLReader` fallback [simplepie#1023](simplepie/simplepie#1023)
  - Bump [#&#8203;9562](FreshRSS/FreshRSS#9562), [FreshRSS/simplepie#96](FreshRSS/simplepie#96)
    - Remove support for local files
    - Ignore whitespace before the XML declaration
    - Treat https Atom 1.0 namespace as Atom
- Deployment
  - Docker: dev image `freshrss/freshrss:oldest` updated to Alpine 3.18 with PHP 8.2.16 and Apache 2.4.62 [#&#8203;9470](FreshRSS/FreshRSS#9470)
  - Docker: dev image `freshrss/freshrss:newest` updated with PHP 8.6.0 and Apache 2.4.71
  - Docker: dev image `freshrss/freshrss:newest` updated to use HTTPs for downloading packages [#&#8203;9584](FreshRSS/FreshRSS#9584)
- UI
  - Add option to open articles on their original website by default [#&#8203;9554](FreshRSS/FreshRSS#9554)
  - <kbd>Esc</kbd> leaves the search box [#&#8203;9462](FreshRSS/FreshRSS#9462)
- Extensions
  - Add `feeds_after_actualize` hook [#&#8203;9438](FreshRSS/FreshRSS#9438)
- I18n
  - Add current English text to `DIRTY` translation comments [#&#8203;9525](FreshRSS/FreshRSS#9525)
  - Add Arabic [#&#8203;9502](FreshRSS/FreshRSS#9502)
  - Improve Portuguese [#&#8203;9573](FreshRSS/FreshRSS#9573), [#&#8203;9583](FreshRSS/FreshRSS#9583)
  - Improve traditional Chinese [#&#8203;9540](FreshRSS/FreshRSS#9540), [#&#8203;9590](FreshRSS/FreshRSS#9590)
- CI/CD
  - Add a link checker workflow using lychee [#&#8203;9209](FreshRSS/FreshRSS#9209), [#&#8203;9495](FreshRSS/FreshRSS#9495),
    [#&#8203;9507](FreshRSS/FreshRSS#9507), [#&#8203;9511](FreshRSS/FreshRSS#9511), [#&#8203;9614](FreshRSS/FreshRSS#9614)
  - Update to PHPUnit 11.x (PHP 8.2+) [#&#8203;9470](FreshRSS/FreshRSS#9470)
  - Group auto dependency updates into one PR per ecosystem [#&#8203;9496](FreshRSS/FreshRSS#9496)
- Misc.
  - New `make test-all-php-versions` to run tests with all supported PHP versions in Docker [#&#8203;9576](FreshRSS/FreshRSS#9576), [#&#8203;9606](FreshRSS/FreshRSS#9606)
  - Fix `make start` stopping on terminal resize [#&#8203;9603](FreshRSS/FreshRSS#9603)
  - Update dev dependencies [#&#8203;9494](FreshRSS/FreshRSS#9494), [#&#8203;9497](FreshRSS/FreshRSS#9497), [#&#8203;9498](FreshRSS/FreshRSS#9498),
    [#&#8203;9499](https://github.com/FreshRSS/FreshRSS/pull/9499),[#&#8203;9500](https://github.com/FreshRSS/FreshRSS/pull/9500),[#&#8203;9501](https://github.com/FreshRSS/FreshRSS/pull/9501),
    [#&#8203;9522](FreshRSS/FreshRSS#9522), [#&#8203;9523](FreshRSS/FreshRSS#9523), [#&#8203;9561](FreshRSS/FreshRSS#9561)

</details>

---

### Configuration

📅 **Schedule**: (in timezone Europe/Rome)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4yNTcuOSIsInVwZGF0ZWRJblZlciI6IjQ0LjI1Ny45IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL21pbm9yIl19-->

Reviewed-on: https://git.aresu.eu/GiorgioAresu/home-ops/pulls/2735
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API 🤝 API for other clients

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Google Reader API edit-tag marks articles read one per transaction on PostgreSQL and SQLite

2 participants