Announcement

Collapse
No announcement yet.

Forum running slow using Template Hook

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Forum running slow using Template Hook

    I used this tutorial to display a custom profile field on my forum. When I activate the Template Hook, it takes about 30+ seconds before a topic is opened. Without using the Template Hook the topic opens at the regular speed.

    Does anyone know what might be wrong?

    Edit:

    It now even send me database error emails:
    Code:
    Database error in vBulletin 5.2.5:
    
                Invalid SQL:
    /** saveDbCache */ DELETE FROM cacheevent WHERE (cacheid = 'node_1454019_lvl1data' AND event = 'nodeChg_1454019')
    
    MySQL Error   : MySQL server has gone away
                Error Number  : 2006
                Classname     : vB_Database_MySQLi
    Last edited by Fleiding; Tue 6th Dec '16, 5:47am.

  • #2
    Forgot about this topic, but there is still a drop in speed if I use Template Hooks. When enabled, it takes significant extra time to open a topic and my inbox is spammed with these errors:

    Code:
    Database error in vBulletin 5.3.0:
    
                Invalid SQL:
    /** saveDbCache */ DELETE FROM cacheevent WHERE (cacheid = 'getSearchResults_9563faad0b6c350982f37386bfc801e4' AND event = 'nodeChg_26878') OR 
    (cacheid = 'getSearchResults_9563faad0b6c350982f37386bfc801e4' AND event = 'perms_changed') OR 
    (cacheid = 'getSearchResults_9563faad0b6c350982f37386bfc801e4' AND event = 'vB_ChannelStructure_chg') OR 
    (cacheid = 'getSearchResults_9563faad0b6c350982f37386bfc801e4' AND event = 'vB_SearchResults_chg_2') OR 
    (cacheid = 'node_1463535_lvl1data' AND event = 'nodeChg_1463535') OR 
    (cacheid = 'node_1463560_lvl1data' AND event = 'nodeChg_1463560') OR 
    (cacheid = 'node_1463564_lvl1data' AND event = 'nodeChg_1463564') OR 
    (cacheid = 'node_1463587_lvl1data' AND event = 'nodeChg_1463587') OR
    My members prefer to have one of my custom profile fields displayed in the postbit, so I really would like to have this Template Hook enabled, but if it continues like this, I have to disable the hook.

    Comment


    • #3
      A lot depends on what the hook is calling.

      Your original error is "MySQL server has gone away". This is a server error and would certainly explain the delay. Your first port of call should be your host.
      MARK.B | vBULLETIN SUPPORT

      TalkNewsUK - My vBulletin 5.6.0 Demo
      AdminAmmo - My Cloud Demo

      Comment


      • Fleiding
        Fleiding commented
        Editing a comment
        Thanks, I'll give them a call.

    • #4
      How big are your cache and cacheevents tables?

      You may need to clear them in the AdminCP under maintenance. While it depends on what your template hook is doing, it seems coincidental with the information provided.
      Translations provided by Google.

      Wayne Luke
      The Rabid Badger - a vBulletin Cloud demonstration site.
      vBulletin 5 API - Full / Mobile
      Vote for your favorite feature requests and the bugs you want to see fixed.

      Comment


      • #5
        cache is 152.9 MiB
        cacheevent is 16.9 MiB

        Comment


        • #6
          Run these two queries:

          DELETE FROM cache
          DELETE FROM cacheevent

          NOTE: Do not run DELETE queries on any other table. You will break your site.
          MARK.B | vBULLETIN SUPPORT

          TalkNewsUK - My vBulletin 5.6.0 Demo
          AdminAmmo - My Cloud Demo

          Comment


          • #7
            I've run the queries but it's still loading slow.

            Comment


            • #8
              What is your template hook code?
              Translations provided by Google.

              Wayne Luke
              The Rabid Badger - a vBulletin Cloud demonstration site.
              vBulletin 5 API - Full / Mobile
              Vote for your favorite feature requests and the bugs you want to see fixed.

              Comment


              • #9
                Hook Argument:

                Code:
                userInfo=userInfo
                Template:

                Code:
                {vb:rawdata userInfo, user, fetchProfileInfo, {vb:raw userInfo.userid}}
                {vb:set fieldlist, {vb:raw vboptions.profile_fields_list}}
                {vb:set fields, {vb:php explode, ',', {vb:raw fieldlist}}}
                <vb:each from="fields" value="field">
                    {vb:set field, {vb:php trim, {vb:raw field}}}
                    {vb:set label, {vb:raw field}}
                    {vb:strcat label, '_title'}
                    {vb:set fieldVal, {vb:raw userInfo[$field]}}
                    <vb:if condition="!empty($fieldVal)">
                        <li class="b-userinfo__additional-info"><label>{vb:phrase {vb:raw label}}:</label> <span>{vb:var fieldVal}</span></li>
                    </vb:if>
                </vb:each>
                
                <vb:if condition="$vboptions['profile_fields_sendpm']">
                    <li class="b-userinfo__additional-info"><a href="{vb:raw baseurl}/privatemessage/new/{vb:raw userInfo.userid}" class="send-pm-in-postbit" rel="nofollow"><span></span>Send PM</a></li>
                </vb:if>

                Comment


                • #10
                  That seems like an expensive hook. How many posts do you show per page? Each post is making an AJAX call to the database to retrieve information.
                  Translations provided by Google.

                  Wayne Luke
                  The Rabid Badger - a vBulletin Cloud demonstration site.
                  vBulletin 5 API - Full / Mobile
                  Vote for your favorite feature requests and the bugs you want to see fixed.

                  Comment


                  • #11
                    20 by default, but I'm having the same if I set it top 10.

                    Comment


                    • #12
                      The first line:
                      Code:
                      {vb:rawdata userInfo, user, fetchProfileInfo, {vb:raw userInfo.userid}}
                      Does a call to the server for each rendering. It depends on your server, PHP and MySQL for speed. The only way to speed it up would be to improve the API calls from templates. That would require an improvement request JIRA.

                      http://tracker.vbulletin.com/secure/...91&issuetype=4

                      Though if you're not using PHP 7.X and MySQL 5.7, you might consider upgrading your server.
                      Translations provided by Google.

                      Wayne Luke
                      The Rabid Badger - a vBulletin Cloud demonstration site.
                      vBulletin 5 API - Full / Mobile
                      Vote for your favorite feature requests and the bugs you want to see fixed.

                      Comment

                      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                      Working...
                      X