• I just looked into the code of calendar.php and I noticed the calendar do 60 SQL statement each time you show a calendar. One statement look like:

    SELECT a.*,'Normal' AS type  FROM wp_calendar AS a WHERE a.event_begin <= '2011-9-30' AND a.event_end >= '2011-9-30' AND a.event_recur = 'S'
    UNION ALL
    SELECT b.*,'Yearly' AS type FROM wp_calendar AS b WHERE b.event_recur = 'Y' AND EXTRACT(YEAR FROM '2011-9-30') >= EXTRACT(YEAR FROM b.event_begin) AND b.event_repeats = 0
    UNION ALL
    SELECT c.*,'Yearly' AS type FROM wp_calendar AS c WHERE c.event_recur = 'Y' AND EXTRACT(YEAR FROM '2011-9-30') >= EXTRACT(YEAR FROM c.event_begin) AND c.event_repeats != 0 AND (EXTRACT(YEAR FROM '2011-9-30')-EXTRACT(YEAR FROM c.event_begin)) <= c.event_repeats
    UNION ALL
    SELECT d.*,'Monthly' AS type FROM wp_calendar AS d WHERE d.event_recur = 'M' AND EXTRACT(YEAR FROM '2011-9-30') >= EXTRACT(YEAR FROM d.event_begin) AND d.event_repeats = 0
    UNION ALL
    SELECT e.*,'Monthly' AS type FROM wp_calendar AS e WHERE e.event_recur = 'M' AND EXTRACT(YEAR FROM '2011-9-30') >= EXTRACT(YEAR FROM e.event_begin) AND e.event_repeats != 0 AND (PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM '2011-9-30'),EXTRACT(YEAR_MONTH FROM e.event_begin))) <= e.event_repeats
    UNION ALL
    SELECT f.*,'MonthSun' AS type FROM wp_calendar AS f WHERE f.event_recur = 'U' AND EXTRACT(YEAR FROM '2011-9-30') >= EXTRACT(YEAR FROM f.event_begin) AND f.event_repeats = 0
    UNION ALL
    SELECT g.*,'MonthSun' AS type FROM wp_calendar AS g WHERE g.event_recur = 'U' AND EXTRACT(YEAR FROM '2011-9-30') >= EXTRACT(YEAR FROM g.event_begin) AND g.event_repeats != 0 AND (PERIOD_DIFF(EXTRACT(YEAR_MONTH FROM '2011-9-30'),EXTRACT(YEAR_MONTH FROM g.event_begin))) <= g.event_repeats
    UNION ALL
    SELECT h.*,'Weekly' AS type FROM wp_calendar AS h WHERE h.event_recur = 'W' AND '2011-9-30' >= h.event_begin AND h.event_repeats = 0
    UNION ALL
    SELECT i.*,'Weekly' AS type FROM wp_calendar AS i WHERE i.event_recur = 'W' AND '2011-9-30' >= i.event_begin AND i.event_repeats != 0 AND (i.event_repeats*7) >= (TO_DAYS('2011-9-30') - TO_DAYS(i.event_end))
    ORDER BY event_id

    the whole idea behind this, is to get a name for the type. If you “EXPLAIN” the query, you see there is no key in use. So I guess you will always get some performance problems if the event calendar grows.

    there are a couple of other issues, I am working at. What I have noticed is, that the plugin don’t use the functions which WordPress provide with the $wpdb class (http://codex.wordpress.org/Class_Reference/wpdb)

    If you have an big growing calendar I would avoid using this plugin.

Viewing 1 replies (of 1 total)
  • Thread Starter struppi

    (@struppi)

    I have included 2 calendars on one page – it’s “only” the half. 30/31 SQL SELECT each time (plus some other to get config params)

Viewing 1 replies (of 1 total)
  • The topic ‘Did anyone look at the SQL Statements?’ is closed to new replies.