Support » Plugin: The Events Calendar » Query on homepage running but not needed

  • Resolved wedideas

    (@wedideas)


    Hello,

    I’ve been running the debug queries plugin to check a few things over on our site and I noticed that the events calendar plugin is querying the db (which is taking around 4s!) but I’m not actually running any events info such as a plugin on this page.

    Why would the database need to be queried even thought there is no events calendar information needed on the homepage?

    Below is an excerpt of the query being run…

    SELECT SQL_CALC_FOUND_ROWS DISTINCT wp_posts.*, IF (wp_posts.post_type = 'tribe_events', wp_postmeta.meta_value, wp_posts.post_date) AS post_date
    FROM wp_posts
    INNER JOIN wp_term_relationships
    ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_postmeta as wp_postmeta on wp_posts.ID = wp_postmeta.post_id
    AND wp_postmeta.meta_key = '_EventStartDate'
    WHERE 1=1
    AND ( wp_term_relationships.term_taxonomy_id IN (289) )
    AND wp_posts.post_type IN ('post', 'tribe_events', 'tribe_events')
    AND (wp_posts.post_status = 'publish'
    OR wp_posts.post_status = 'private')
    GROUP BY wp_posts.ID
    ORDER BY post_date DESC
    LIMIT 0, 8

    https://wordpress.org/plugins/the-events-calendar/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter wedideas

    (@wedideas)

    Is there a way to exclude the tribe_events loop from running on our homepage?

    Brook

    (@brook-tribe)

    Howdy wedideas,

    Are you perchance running a TEC widget, or have you set th e plugin to include events in the main blog loop?

    If you do not mind me asking, what host are you using? That query should not take 4 seconds! That’s insane.

    Cheers!

    – Brook

    Thread Starter wedideas

    (@wedideas)

    Hi Brook,

    We are running an events widget in the sidebar, but the problem still exists when I make the widget inactive, clear cache and refresh so it isn’t related to this.

    The plugin option to include events in the main loop is unchecked. I’m going to check it, save and uncheck it to see if this solves it but don’t hold much hope.

    Is there a function/filter I could use to ask the calendar to not run on the homepage loop? (obviously we would still want to the widget to function)

    Thanks,

    James

    Thread Starter wedideas

    (@wedideas)

    Hi Brook,

    FYI I have saved both checked and unchecked ‘include in main loop’ options and the problem is still persisting, although it seems totally random. Sometimes it causes a problem, sometimes it doesn’t.

    James

    Thread Starter wedideas

    (@wedideas)

    Hi Brook, any update on how I can stop this from happening?

    Thanks,

    James

    Brook

    (@brook-tribe)

    Hello again wedidas,

    One thing that stuck out to me from the beginning is that this query should not be taking 4 seconds! That’s insane. I just ran it on my rather unoptimized slow HDD test server and it took .1 seconds. That is one of the reasons why I was asking what host you are using. If you are willing to share that info it would be good for us to know.

    But still .1 seconds is no good if the query ahs no business running. I am going to see if I can replicate that problem with some further testing, and if so hopefully i can isolate it so we can stop that from happening in a future release of our plugin.

    In the mean time, if that query is slowing down your site like that it is possible that your server is severely underpowered. While serving webpages from a TI-83 calculator with a spud-based battery is novel, I don’t recommend it for production sites. I jest of course. But, in seriousness unless there is something exotic about your setup it might be time for an upgrade. Even once we stop that query from running, it would seem like the site will be unusably slow. Please let me know if there is something I have no considered here. But I am racking my brain trying to figure why that query would take 4 seconds, and coming up blank. It should not noticeably delay the site at all. Cheers!

    – Brook

    Thread Starter wedideas

    (@wedideas)

    Hi Brook, we’re with TSO Host and we’re using the Powerhouse VPS which has 8x zeon core with 8gb RAM so I don’t think it’s going to be a hardware issue.

    This problem is only affecting the homepage with or without the sidebar widget.

    Where is the code that hooks into the main loop? Is it possible to override that function in our functions.php to not run on the homepage?

    Thanks again.

    James

    Thread Starter wedideas

    (@wedideas)

    Hi Brook,

    any update on this as it’s been over 2 weeks now and need to get this sorted.

    Appreciate your time,

    James

    Brook

    (@brook-tribe)

    Howdy James,

    I do appreciate your patience. I was able to recreate that query you are seeing on my home page, but only if I had checked the option “Include events in main blog loop” which is found in WP Admin > Events > Settings. When I unchecked it, the code disappeared (I even did Ctrl + F just to double check on each step). When I rechecked the box, that query came back. In the end it’s not a useless query. If it is appearing for you and you have unchecked the box, that is a bit strange. Any number of things are possible. Something might have corrupted that entry in your DB. Another plugin, your theme, or a different bit of code is preventing that setting from updating properly. WP itself might even be a bit screwy.

    I should mention that here on the .org forums Leah and I do a combined pass once a week helping support the free plugin and responding to topics. Amongst the benefits of a PRO license is that it gives you access to our PRO forums which a team of us checks multiple times every week day. If you are in need of faster and more hands on assistance, that might be something you would be interested. But again, I appreciate your patience and am certainly not trying to shoe you away or anything like that. Just wanted you to be aware of the options.

    Does that all make sense? Thanks, James.

    – Brook

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Query on homepage running but not needed’ is closed to new replies.