WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Too many events? (6 posts)

  1. ian72
    Member
    Posted 1 year ago #

    Using EM Version 5.2.6

    I'm the go-to wordpress guy for a community website which has lots of events - about 5 per day.
    Folks were happily adding daily occurring events that didn't stop recurring until 2016. As far as they're concerned, that shouldn't be a problem.

    However, it brought the admin page to its knees and eventually they were unable to add any events - the add event page was just blank. I think this was a combination of memory overload (upping the config to 256Mb didn't help) and the script timing out. There was nothing in the error logs specifically to help route out the problem.
    Strangely enough, all other parts of the plugin worked fine...

    So I have started to cut down on the 9000+ events that are published.
    Trouble is, if I edit a previously published recurring event template and change the dates, not all posts are removed properly.

    I now see that EM uses now custom post types so using phpMyAdmin to edit stuff is that much more difficult.

    Can some clever person give me some hints as to how to slim down my events without having to go through one at a time - I guess I just need a groovy relational mysql call - I just don't know what that is!

    Thanks in advance

    http://wordpress.org/extend/plugins/events-manager/

  2. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    Have you tried the bulk delete feature in the admin area?

    SQL is possible too, but I'd need to know more about what exactly you want to delete, i.e. is it just recurrences from the past?

  3. ian72
    Member
    Posted 1 year ago #

    Hey Marcus, thanks for replying.

    For events that HAVE passed, but are still part of a recurring set of events that have NOT completely passed, I get the impression that I have to Detach the event before I can bulk delete or the whole lot get deleted?

    SQL- I'm looking to delete events that with an end_date before a specific date (today for example) and as a separate query, events whose start_date is after a certain date (next year for example)

    Before I realised EM'd changed to custom posts (doh!), I was doing something like this in phpMyadmin

    DELETE FROM em_events WHERE  event_end_date < 2012-10-03

    and

    DELETE FROM em_events WHERE event_start_date > 2013-10-03

    Cheers

  4. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    You'd want something like

    (disclaimer - hand written, not tested, use at own risk)

    The select statement you'll nest rmains the same so I'll paste it once, replace the ... in the further statements

    SELECT post_id FROM wp_em_events WHERE event_end_date < NOW() AND recurrence_id > 0

    that gets all your past events that are recurrences

    DELETE FROM wp_postmeta WHERE object_id IN (...)
    DELETE FROM wp_postmeta WHERE post_id IN (...)
    DELETE FROM wp_posts WHERE ID IN (...)
    DELETE FROM wp_em_events WHERE event_end_date < NOW() AND recurrence_id > 0

    I think that clears all the relevant info. If you find any errors/typos would appreciate a heads up to save grief for others :)

  5. ian72
    Member
    Posted 1 year ago #

    I've done as suggested but Im still not deleting the previous events properly.

    You were pretty much bang with the statements apart from the first DELETE statement. because object_id doesn't exist as a column in wp_em_events
    Am I missing something here?

    Although this has deleted a whole bunch of stuff (see below) I still have lots of previous events showing in the admin.
    So, I looked at the post_id in WordPress for one of the previous events, and can see that there are still many instances in wp_postmeta with the related post_id. They have not been deleted properly.
    Looking at the sql calls, I don't think the logic is quite right, but Im too daft to work out the right thing.
    It would help if I knew which tables were in operation - is wp_em_events even still in the mix? Thought wp_posts had taken over.

    For the record here's what I did
    *I tried all these out first replacing DELETE with SELECT * to check the syntax was OK and the tables existed etc.

    1.

    DELETE
    FROM wp_postmeta
    WHERE post_id
    IN (
    SELECT post_id
    FROM wp_em_events
    WHERE event_end_date < NOW( )
    AND recurrence_id >0
    )

    Deleted rows: 25785 (Query took 5.9513 sec)

    2.

    DELETE
    FROM wp_posts
    WHERE ID
    IN (
    SELECT post_id
    FROM wp_em_events
    WHERE event_end_date < NOW( )
    AND recurrence_id >0
    )

    Deleted rows: 849 (Query took 0.1698 sec)

    3.

    DELETE FROM wp_em_events WHERE event_end_date < NOW() AND recurrence_id > 0

    Deleted rows: 887 (Query took 0.1382 sec)

  6. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    from the looks of it there's a disconnect between queries 3 and 1, they should be the same rows affected.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic