Urgent help required for stupidity (mine!)

Home Forums Calendar Products Events Calendar PRO Urgent help required for stupidity (mine!)

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #55279
    gregwiley
    Participant

    I just got an e-mail from my hosting provider saying they are blocking access to my database because of a query that is taking up too many resources on the shared host. The query in question is:

    SELECT meta_id FROM wp_postmeta WHERE meta_key=’_EventStartDate’ AND post_id IN (

    SELECT post_id FROM wp_postmeta WHERE meta_key=’_EventStartDate’ GROUP BY post_id HAVING COUNT(meta_key) > 1 ) AND meta_id NOT IN ( SELECT meta_id FROM wp_postmeta WHERE meta_key=’_EventStartDate’ GROUP BY post_id HAVING MIN(CAST(meta_value AS DATETIME)) )

    As you can see it comes for The Event Calendar. It’s not necessarily the plugins fault but I stupidly created a number of events with recurrences of 1000 which has resulted in a large postmeta table in my WordPress database.

    What I’d really like is for someone to identify a way I can delete all the Event Calendar entries using phpmyadmin so that I can start my event calendar afresh following the 3.0 upgrade.

    Cheers, Greg.

    #55486
    Barry
    Member

    Hi Greg,

    With large numbers of long-lived recurring events problems like this probably will crop up and you’re right – realistically there probably isn’t a massive amount we can do about that.

    Before I go any further with your second question about deleting The Events Calendar content, I want to stress that if you do this you do so at your own risk and should take all necessary precautions first of all (namely, backup and know the process for restoring the backup).

    The basic form of a query to delete events is:

    DELETE FROM db.name.wp_posts WHERE wp_posts.post_type = 'tribe_events';

    It’s important to understand that, because of the way in which WordPress works, the data for an event (this also applies to venues tribe_venue and organizers tribe_organizer) is primarily split across two different tables – the posts table and the postmeta table. This is a one-to-many relationship – there are typically multiple postmeta entries that relate to any single post entry.

    A single delete query like the one I provided above only affects one of those tables and would leave you with a number of “orphans” in the post meta table. That probably isn’t a problem in itself other than being untidy and consuming space that could be better spent on valid entries. If you’re good with SQL you may be able to devise a way around this, or else you might alternatively be interested in removing events programmatically with a pre-existing WordPress API function like wp_delete_post() which can take care of cleaning up any meta data at the same time.

    One other quite different approach would be to use Tools > Export to export everything but event-related posts, then delete everything from the posts and posts meta tables – and re-import.

    Last but not least, do not forget about The Events Calendar’s options data: you can locate these entries with a query something like:

    SELECT * FROM db.name.wp_options WHERE option_name LIKE '%tribe%';

    #55536
    gregwiley
    Participant

    Thanks Barry. I figured the wp_posts delete query out. The postsmeta was a little trickier but essentially a DELETE on meta_key LIKE %_Event% and LIKE %_Venue% sorted most of it out.

    I wasn’t removing the plugin so I didn’t need to remove the options data; I just needed to ‘reset’ the events database as my hosting provider had restricted access to it until I resolved the issue:(

    #55563
    Barry
    Member

    Cool, sounds like you’re on track in that case – do you need any further assistance with this specific issue?

    #55567
    gregwiley
    Participant

    No, it’s all good, thanks. You can close this thread.

    Cheers, Greg.

    #55577
    Barry
    Member

    Great, thanks! I hope all else is plain sailing for you 🙂

    #980194
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Urgent help required for stupidity (mine!)’ is closed to new replies.