Topic List Previews (legacy)

FYI everything seems to be working great, the conflict with events/mobile does still exist though.

2 Likes

I’ll take care of this in a few hours.

p.s. I made that change. Now the TLP template should load on mobile with the event details.

2 Likes

thanks @fzngagan

So now I see an event on the topic list on mobile fine using the TC. Can you please confirm @davidkingham?

1 Like

That’s personal choice. TLP has been around longer and in part that is why it is more feature rich (Thumbnail chooser, Featured Images, User Portfolio system, support for Suggested Topics), it has a slightly different Tiles format with more meta data, TLTTC has an additional view type (grid).

1 Like

Hi, thanks for the great plugin!

Unfortunately, with the last update, the images which do not hosted directly on discourse don’t show up on Grid or Tiles anymore. Could you please check that?

For example, it the post has image from other server (blogger, picasa, …) then they don’t show up anymore. Previously, it works great without any problem.

1 Like

Thumbnails are now generated by Discourse core and I have little influence over that now.

Much of the thumbnail generation logic has been stripped out and left to Discourse.

You might want to raise that here: Theme modifiers: A brief introduction

2 Likes

Thanks! I just create a reply there. It’s a bit skeptical with all the updates since all my images is not hosted on local server.

2 Likes

I believe it should still work if your ‘uploads’ are hosted on a remote server via settings, but it will no longer hotlink to remote sites and non-affiliated third parties.

It no longer makes sense to manage this part of the code-base in the plugin given it’s now handled by core. It’s absolutely right you follow up with them :+1:

4 Likes

Thanks. I understand the situation. It’s not an easy fix for my site since we’re using other server to host the images. Now it’s too difficult to move to affiliated server with many posts, while it’s too big for hosting on local sever.

1 Like

The problem I’m having is that when the events plugin is enabled the thumbnails no longer show on mobile as discussed before, I thought this is what you were referring to.

Thumbnails are showing fine for me. Are you sure you’ve updated Events as per @fzngagan?

2 Likes

He must have merged that right after I had tested it, thanks guys, all is working now!

3 Likes

I updated yesterday and I’ve been getting rather poor performance. Digging into the profiler shows me this query by TLP that seems to be the culprit - perhaps there’s an index missing here?

Interestingly enough, this query still shows up when I run the site in safe mode :thinking:

1 Like

Features Images. This query has not changed in forever (like years!). Are you sure this is a new issue?

Are you ordering by tag created date? That’s almost bound to be a convoluted query. Ordering by Latest will be kinder.

You can always switch this feature off for time being.

The Theme Component uses the core API. You could always switch and use that for time being if it’s hurting you.

1 Like

It’s new since I upgraded to PG12 I guess. And we do need sorting by tag created date, that’s rather a core ‘feature’ of our community. What would I miss if I switched to the TC?

Ps: I vaguely remember discussing the same issue with the featured row with you years ago, I’ll do some digging.

2 Likes

Are you sure PG 12 upgrade has finished re-indexing? A lot of users were reporting a period of reduced performance whilst this process took place (and those reports were not related to TLP)

Btw actually thinking about it something else might have changed as now has to join with topic_thumbnails, but that was also a while ago and not had any other reports. I suspect before it just used image_url hotlink in the Topic object which would have been faster (one less join) but that’s no longer open to us with core change. That might be contributing.

1 Like

Yeah, the reindexing has finished. Sorting by topic creation date has the same issue. Here’s the EXPLAIN output for both queries:

Sorted by tagging date:

discourse=# explain SELECT "topics"."id", "topics"."title", "topics"."last_posted_at", "topics"."created_at", "topics"."updated_at", "topics"."views", "topics"."posts_count", "topics"."user_id", "topics"."last_post_user_id", "topics"."reply_count", "topics"."featured_user1_id", "topics"."featured_user2_id", "topics"."featured_user3_id", "topics"."deleted_at", "topics"."highest_post_number", "topics"."like_count", "topics"."incoming_link_count", "topics"."category_id", "topics"."visible", "topics"."moderator_posts_count", "topics"."closed", "topics"."archived", "topics"."bumped_at", "topics"."has_summary", "topics"."archetype", "topics"."featured_user4_id", "topics"."notify_moderators_count", "topics"."spam_count", "topics"."pinned_at", "topics"."score", "topics"."percent_rank", "topics"."subtype", "topics"."slug", "topics"."deleted_by_id", "topics"."participant_count", "topics"."word_count", "topics"."excerpt", "topics"."pinned_globally", "topics"."pinned_until", "topics"."fancy_title", "topics"."highest_staff_post_number", "topics"."featured_link", "topics"."reviewable_score", "topics"."image_upload_id" 
discourse-# FROM "topics" 
discourse-# INNER JOIN "topic_tags" 
discourse-# ON "topic_tags"."topic_id" = "topics"."id" 
discourse-# INNER JOIN "tags" ON "tags"."id" = "topic_tags"."tag_id" 
discourse-# WHERE ("topics"."deleted_at" IS NULL) 
discourse-# AND "topics"."visible" = TRUE 
discourse-# AND (NOT topics.closed AND NOT topics.archived AND topics.deleted_at IS NULL) 
discourse-# AND (topics.image_upload_id in (
discourse(#         SELECT image_upload_id FROM topic_thumbnails
discourse(#       ))
discourse-# AND (tags.id IN (1)) 
discourse-# 
discourse-# ORDER BY (
discourse(#  SELECT created_at FROM topic_tags
discourse(#         WHERE topic_id = topics.id
discourse(#         AND tag_id IN (1)
discourse(#         LIMIT 1
discourse(# )
discourse-# 
discourse-# DESC LIMIT 6; 
                                                                    QUERY PLAN                                                         
            
---------------------------------------------------------------------------------------------------------------------------------------
------------
 Limit  (cost=2631719.94..2631719.95 rows=6 width=569)
   ->  Sort  (cost=2631719.94..2631721.73 rows=717 width=569)
         Sort Key: ((SubPlan 1)) DESC
         ->  Nested Loop  (cost=0.43..2631707.09 rows=717 width=569)
               ->  Seq Scan on tags  (cost=0.00..4.51 rows=1 width=4)
                     Filter: (id = 1)
               ->  Nested Loop  (cost=0.43..2625737.13 rows=717 width=565)
                     ->  Seq Scan on topic_tags  (cost=0.00..860.33 rows=1539 width=8)
                           Filter: (tag_id = 1)
                     ->  Index Scan using topics_pkey on topics  (cost=0.43..1705.57 rows=1 width=561)
                           Index Cond: (id = topic_tags.topic_id)
                           Filter: ((deleted_at IS NULL) AND visible AND (NOT closed) AND (NOT archived) AND (deleted_at IS NULL) AND (
SubPlan 2))
                           SubPlan 2
                             ->  Seq Scan on topic_thumbnails  (cost=0.00..2966.64 rows=171664 width=8)
               SubPlan 1
                 ->  Limit  (cost=0.29..8.31 rows=1 width=8)
                       ->  Index Scan using index_topic_tags_on_topic_id_and_tag_id on topic_tags topic_tags_1  (cost=0.29..8.31 rows=1
 width=8)
                             Index Cond: ((topic_id = topics.id) AND (tag_id = 1))
 JIT:
   Functions: 25
   Options: Inlining true, Optimization true, Expressions true, Deforming true
(21 rows)

sorted by topic date:

discourse=# explain SELECT "topics"."id", "topics"."title", "topics"."last_posted_at", "topics"."created_at", "topics"."updated_at", "topics"."views", "topics"."posts_count", "topics"."user_id", "topics"."last_post_user_id", "topics"."reply_count", "topics"."featured_user1_id", "topics"."featured_user2_id", "topics"."featured_user3_id", "topics"."deleted_at", "topics"."highest_post_number", "topics"."like_count", "topics"."incoming_link_count", "topics"."category_id", "topics"."visible", "topics"."moderator_posts_count", "topics"."closed", "topics"."archived", "topics"."bumped_at", "topics"."has_summary", "topics"."archetype", "topics"."featured_user4_id", "topics"."notify_moderators_count", "topics"."spam_count", "topics"."pinned_at", "topics"."score", "topics"."percent_rank", "topics"."subtype", "topics"."slug", "topics"."deleted_by_id", "topics"."participant_count", "topics"."word_count", "topics"."excerpt", "topics"."pinned_globally", "topics"."pinned_until", "topics"."fancy_title", "topics"."highest_staff_post_number", "topics"."featured_link", "topics"."reviewable_score", "topics"."image_upload_id" FROM "topics" INNER JOIN "topic_tags" ON "topic_tags"."topic_id" = "topics"."id" INNER JOIN "tags" ON "tags"."id" = "topic_tags"."tag_id" WHERE ("topics"."deleted_at" IS NULL) AND "topics"."visible" = TRUE AND (NOT topics.closed AND NOT topics.archived AND topics.deleted_at IS NULL) AND (topics.image_upload_id in (
        SELECT image_upload_id FROM topic_thumbnails
      )) AND (tags.id IN (1)) ORDER BY (SELECT created_at FROM topic_tags
        WHERE topic_id = topics.id
        AND tag_id IN (1)
        LIMIT 1)
        DESC LIMIT 6; 
                                                                    QUERY PLAN                                                         
            
---------------------------------------------------------------------------------------------------------------------------------------
------------
 Limit  (cost=2631719.94..2631719.95 rows=6 width=569)
   ->  Sort  (cost=2631719.94..2631721.73 rows=717 width=569)
         Sort Key: ((SubPlan 1)) DESC
         ->  Nested Loop  (cost=0.43..2631707.09 rows=717 width=569)
               ->  Seq Scan on tags  (cost=0.00..4.51 rows=1 width=4)
                     Filter: (id = 1)
               ->  Nested Loop  (cost=0.43..2625737.13 rows=717 width=565)
                     ->  Seq Scan on topic_tags  (cost=0.00..860.33 rows=1539 width=8)
                           Filter: (tag_id = 1)
                     ->  Index Scan using topics_pkey on topics  (cost=0.43..1705.57 rows=1 width=561)
                           Index Cond: (id = topic_tags.topic_id)
                           Filter: ((deleted_at IS NULL) AND visible AND (NOT closed) AND (NOT archived) AND (deleted_at IS NULL) AND (
SubPlan 2))
                           SubPlan 2
                             ->  Seq Scan on topic_thumbnails  (cost=0.00..2966.64 rows=171664 width=8)
               SubPlan 1
                 ->  Limit  (cost=0.29..8.31 rows=1 width=8)
                       ->  Index Scan using index_topic_tags_on_topic_id_and_tag_id on topic_tags topic_tags_1  (cost=0.29..8.31 rows=1
 width=8)
                             Index Cond: ((topic_id = topics.id) AND (tag_id = 1))
 JIT:
   Functions: 25
   Options: Inlining true, Optimization true, Expressions true, Deforming true
(21 rows)
2 Likes

Useful. Thanks.

Sorry not sure when I can get to this.

Also be aware the new join might be improved but I cannot get rid of it. (oh yes I could!).

1 Like

OK I’ve worked with @bartv offline to improve this.

This only affects the Plugin, not the TC:

https://github.com/paviliondev/discourse-topic-previews/pull/158

I recommend upgrading to take advantage as this is a big improvement for sites using Featured Images.

5 Likes

You’re a rockstar! :guitar:

3 Likes