Describe the problem you’re having:
Loading articles in the special ‘all articles’ feed is quite slow, as in takes seconds. (Other queries/actions are quite fast, as in take tens of milliseconds.)
tt-rss version (including git commit id):
d7973fe1b
Platform (i.e. Linux distro, PHP, PostgreSQL, etc) versions:
Arch Linux, PHP 7.4.12, PostgreSQL 12.5
PostgreSQL has an effective_cache_size of 3 GB, shared_buffers of 1 GB, work_mem of 32 MB.
select count(*) from ttrss_entries;
count
--------
247063
The responsible query is this:
Summary
EXPLAIN ANALYZE SELECT DISTINCT date_entered, to_char(date_entered, 'IYYY-IW') AS yyiw, guid, ttrss_entries.id,ttrss_entries.title, updated, label_cache, tag_cache, always_display_enclosures, site_url, note, num_comments, comments, int_id, uuid, lang, hide_images, unread,feed_id,marked,published,link,last_read,orig_feed_id, last_marked, last_published, ttrss_feeds.title AS feed_title,favicon_avg_color, content, author,score
FROM
ttrss_entries LEFT JOIN ttrss_user_entries ON (ref_id = ttrss_entries.id)
LEFT JOIN ttrss_feeds ON (feed_id = ttrss_feeds.id)
WHERE
ttrss_user_entries.owner_uid = '2' AND
true ORDER BY updated DESC
LIMIT 30 OFFSET 0;
And the analysis:
Summary
Limit (cost=184978.79..184981.19 rows=30 width=819) (actual time=2500.231..2500.277 rows=30 loops=1)
-> Unique (cost=184978.79..204332.55 rows=241922 width=819) (actual time=2500.229..2500.272 rows=30 loops=1)
-> Sort (cost=184978.79..185583.60 rows=241922 width=819) (actual time=2500.226..2500.241 rows=30 loops=1)
Sort Key: ttrss_entries.updated DESC, ttrss_entries.date_entered, (to_char(ttrss_entries.date_entered, 'IYYY-IW'::text)), ttrss_entries.guid, ttrss_entries.id, ttrss_entries.title, ttrss_user_entries.label_cache, ttrss_user_entries.tag_cache, ttrss_feeds.always_display_enclos...
Sort Method: external merge Disk: 181736kB
-> Hash Left Join (cost=11.46..75695.41 rows=241922 width=819) (actual time=0.360..1277.200 rows=241777 loops=1)
Hash Cond: (ttrss_user_entries.feed_id = ttrss_feeds.id)
-> Merge Join (cost=1.48..74414.99 rows=241922 width=731) (actual time=0.095..994.593 rows=241777 loops=1)
Merge Cond: (ttrss_entries.id = ttrss_user_entries.ref_id)
-> Index Scan using ttrss_entries_pkey on ttrss_entries (cost=0.42..57357.95 rows=247221 width=615) (actual time=0.050..430.654 rows=247064 loops=1)
-> Index Scan using ttrss_user_entries_ref_id_index on ttrss_user_entries (cost=0.42..13426.46 rows=241922 width=120) (actual time=0.036..229.041 rows=241777 loops=1)
Filter: (owner_uid = 2)
Rows Removed by Filter: 5287
-> Hash (cost=8.88..8.88 rows=88 width=60) (actual time=0.158..0.159 rows=88 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 17kB
-> Seq Scan on ttrss_feeds (cost=0.00..8.88 rows=88 width=60) (actual time=0.025..0.091 rows=88 loops=1)
Planning Time: 2.134 ms
Execution Time: 2549.373 ms
Any options how to improve this? Tuning to PostgreSQL config, to tt-rss’ schema, to the query itself? Or will only faster hardware speed this up?