Search

bbPress Showcase » Plugins by _ck_

topic views - query count

RSS

  1. andersson
    User has not uploaded an avatar

    member
    Joined: Apr '08
    Posts: 11

    offline

    EDIT: made the question more direct.

    ck,

    just wondering if you know what this can be:

    In your topic views plugin, get_view_count() I never get the
    if (isset($topic->views) && $topic->topic_id===$topic_id) {return $topic->views;}

    line to be true i.e. it never uses the cached values. Instead, it always makes one db call for each topic which is really ugly.

    Just wondering if you know why the cache for topics seem to be ignored here.

    Thanks.

    ....

    # 37 : 0.028 seconds
    SELECT meta_value FROM bb_meta WHERE object_type='bb_topic' AND object_id = 482 AND meta_key='views'

    # 38 : 0.0013 seconds
    SELECT meta_value FROM bb_meta WHERE object_type='bb_topic' AND object_id = 456 AND meta_key='views'

    # 39 : 0.0022 seconds
    SELECT meta_value FROM bb_meta WHERE object_type='bb_topic' AND object_id = 479 AND meta_key='views'

    # 40 : 0.0013 seconds
    SELECT meta_value FROM bb_meta WHERE object_type='bb_topic' AND object_id = 478 AND meta_key='views'

    # 41 : 0.001 seconds
    SELECT meta_value FROM bb_meta WHERE object_type='bb_topic' AND object_id = 452 AND meta_key='views'

    # 42 : 0.0025 seconds
    SELECT meta_value FROM bb_meta WHERE object_type='bb_topic' AND object_id = 34 AND meta_key='views'

    # 43 : 0.0013 seconds
    SELECT meta_value FROM bb_meta WHERE object_type='bb_topic' AND object_id = 480 AND meta_key='views'

    # 44 : 0.0083 seconds
    SELECT meta_value FROM bb_meta WHERE object_type='bb_topic' AND object_id = 474 AND meta_key='views'

    # 45 : 0.0014 seconds
    SELECT meta_value FROM bb_meta WHERE object_type='bb_topic' AND object_id = 477 AND meta_key='views'

    Posted 3 years ago #
  2. _ck_
    _ck_

    senior admin
    Joined: Jul '06
    Posts: 884

    offline

    I didn't write the original plugin but now that I have ownership of it I plan to improve it.

    What page did you see those queries on?

    Posted 3 years ago #
  3. andersson
    User has not uploaded an avatar

    member
    Joined: Apr '08
    Posts: 11

    offline

    ok. I see.

    As I see it it would be good if it could get the topic ID's and append the meta to the topic in one go like so:

    where object_id IN ([topic_id], ... , [topic_id]) bla bla

    and then make sure its appended to the topic cache.

    Thanks anyways for the VERY fast reply.

    Posted 3 years ago #
  4. _ck_
    _ck_

    senior admin
    Joined: Jul '06
    Posts: 884

    offline

    bbPress should automatically pull in all meta data for a topic.

    What page did you see those queries on?

    Posted 3 years ago #
  5. _ck_
    _ck_

    senior admin
    Joined: Jul '06
    Posts: 884

    offline

    What happens if you change line 66 to this:

    if (isset($topic->views) && ($topic_id==0 || $topic->topic_id===$topic_id)) {return $topic->views;}	// bypass db for cached data
    Posted 3 years ago #
  6. andersson
    User has not uploaded an avatar

    member
    Joined: Apr '08
    Posts: 11

    offline

    The frontpage and the single forum page, well basically any page that loops through topics.

    Posted 3 years ago #
  7. _ck_
    _ck_

    senior admin
    Joined: Jul '06
    Posts: 884

    offline

    Also, what version of 1.0 are you using?

    The cache works on my trunk copy.

    Posted 3 years ago #
  8. andersson
    User has not uploaded an avatar

    member
    Joined: Apr '08
    Posts: 11

    offline

    I use the trunk as well, but this copy is a couple of weeks old now. Probably around alpha 2.

    Hmmm.... that's strange.

    I wonder if I'm doing something funny to $topics to make them not cache properly.

    Thanks for the info. I'll let you know how it goes.

    Meanwhile, you can set this to resolved. i think the problem is very much local with me and not your plugin. Sorry for the inconveience.

    Posted 3 years ago #
  9. _ck_
    _ck_

    senior admin
    Joined: Jul '06
    Posts: 884

    offline

    You still there? I have a new version to try.

    In any case, look for 1.6.3 on bbpress.org and let me know.

    I made it very aggressive in trying to find the cached data.

    Posted 3 years ago #
  10. andersson
    User has not uploaded an avatar

    member
    Joined: Apr '08
    Posts: 11

    offline

    Now I'm here.

    It's now working. It was totally my bad.

    In this particular installation I bypass the BB_Query for getting the topics and do my own query for getting the topics (using $bbdb->get_results directly).

    I had forgotten to add a call to bb_append_meta after the call was made, so I could get the meta for all topics in one go.

    Again, sorry for the inconvenience.

    Posted 3 years ago #

RSS feed for this topic

Post a reply to “topic views - query count” »

You must log in to post.

keep _ck_ coding >> donate $5 <<     Theme Switcher:
38 users online from in the past 30 minutes. 18 bots 20 guests
1,783 views today 8,665 yesterday 14,010 peak. Most at once 43 today 48 yesterday 131 peak. Visited today: Dickinsonjohn9, shairah27, xiaotian
2,245 posts in 385 topics over 63 months by 426 of 1,989 members. Latest: dxdiag02, Pablo01, Dickinsonjohn9