Home › Forums › Calendar Products › Events Calendar PRO › This Query takes longer than 10 minutes
- This topic has 6 replies, 2 voices, and was last updated 12 years, 1 month ago by
Barry.
-
AuthorPosts
-
February 5, 2014 at 9:05 pm #101252
Sonny Parlin
ParticipantAfter setting up a MySQL slow log to find out why our database has been recently getting overloaded, the log showed this query taking longer than 10 minutes, and the log is full of them. Can someone explain to me what exactly this query is doing and what part of the plugin executes it?
SELECT Max(lat) max_lat,
Max(lng) max_lng,
Min(lat) min_lat,
Min(lng) min_lng
FROM (SELECT post_id AS venue_id,
CASE
WHEN meta_key = ‘_VenueLat’ THEN meta_value
end AS LAT,
CASE
WHEN meta_key = ‘_VenueLng’ THEN meta_value
end AS LNG
FROM wp_postmeta
WHERE ( meta_key = ‘_VenueLat’
OR meta_key = ‘_VenueLng’)
AND post_id IN (SELECT meta_value FROM wp_postmeta WHERE meta_key=’_EventVenueID’)
) coors;February 6, 2014 at 4:41 pm #101689Barry
MemberHi!
We are aware that query can be a fairly intensive one, and so its result is actually cached so that it doesn’t need to run on every single page load. It’s role is essentially to calculate the geographic centre of all events that have geolocation data attached to them (so that the map in map view can be appropriately centred, etc).
I would note that we may anyway be revising this as it currently pulls in events that have since passed or are not published – and that may be part of the reason you are hitting this issue.
We’d certainly be interested to know how many events you have that might cause such a long delay, though – can you provide even an approximate figure?
February 6, 2014 at 5:21 pm #101739Sonny Parlin
ParticipantHere is are the numbers:
I’m not sure why we have so many drafts, but these are the numbers. Maybe have that query exclude drafts?February 7, 2014 at 6:12 am #101853Barry
MemberThanks for sharing those details: yes, I can envision there being problems under those circumstances – and we do have an issue on the tracker to address just this point. Ordinarily we don’t recommend tampering with core plugin code but in this case, if you feel comfortable doing so, you might be able to get some relief here by editing the following file:
events-calendar-pro/lib/tribe-geoloc.class.phpThe method we’re interested in is TribeEventsGeoLoc::estimate_center_point() which lives in lines 723-764. Within that if you look for the following line:
set_transient( self::ESTIMATION_CACHE_KEY, $data, 5000 );This sets the number of seconds that the geographic centre is cached for. Changing 5000 to something like 604800 (one week) or 2419200 (one month) would result in this running less frequently – and if your events generally take place in the same area then that is probably a valid way to go.
set_transient( self::ESTIMATION_CACHE_KEY, $data, 604800 );The major downside to editing core code is of course having to restore changes after updates, but though I can’t offer up any guarantees I’d like to think we will have a better solution (at least so you can set up a filter to achieve the same thing) available in one of our next releases.
Thanks again – and apologies for the inconvenience in the interim.
February 7, 2014 at 12:47 pm #102007Sonny Parlin
ParticipantI’ve made the changes, I guess it’s wait and see time. Thanks for your help! I’m going to keep the issue open so I can post updates.
February 8, 2014 at 1:16 pm #102367Sonny Parlin
ParticipantThis appears to have resolved the issue, or at least gave us some relief. Thanks!
March 27, 2014 at 11:30 am #123885Barry
MemberHi! We’ve now completed some work that ought to further address this issue in our very next upcoming release. Thanks for your patience and if you do hit any further problems with this once you’ve updated please don’t hesitate to let us know in a new thread – thanks!
-
AuthorPosts
- The topic ‘This Query takes longer than 10 minutes’ is closed to new replies.
