Skip to content

[Bug] Long wait fetching more articles due to tag unread count #8342

@pe1uca

Description

@pe1uca

Describe the bug

While scrolling the site in the normal view and reaching the end of the loaded articles, the next batch takes a few minutes to load.

I was able to track the issue to this query
Which has taken 90 seconds when I ran it using the \timing option directly in psql in my user with millions of rows in the table _entry

$sql = <<<'SQL'
SELECT t.id, t.name, count(e.id) AS unreads
FROM `_tag` t
LEFT OUTER JOIN `_entrytag` et ON et.id_tag = t.id
LEFT OUTER JOIN `_entry` e ON et.id_entry = e.id AND e.is_read = 0
GROUP BY t.id
ORDER BY t.name
SQL;

Workaround

I changed count(e.id) AS unreads to 0 AS unreads, since this value is not important for me to see, and the query now takes 18ms.

To Reproduce

  1. Set up an instance
  2. Have millions of entries
  3. Scroll through the "Normal view" and see the long wait times to load the next batch of entries.

Expected behavior

Not have to wait 1 or 2 minutes to read the next batch of articles in my feeds.

FreshRSS version

1.27.2-dev

System information

  • Database version: PostgreSQL 17
  • PHP version: 8.4.11
  • Installation type: Docker compose (image: freshrss/freshrss:edge)
  • Browser:Firefox 146

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug (unconfirmed)issues that could not be reproduced yet

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions