WordPress/meeting-calendar

Add object caching of meeting queries

dd32 opened this issue · 0 comments

dd32 commented

The posts queries from the plugin are uncached and can sometimes be "expensive" comparatively to other queries due to their complexity.

Example query, which takes >5ms on WordPress.org:

SELECT wp_posts.*
FROM wp_posts
INNER JOIN wp_postmeta
   ON ( wp_posts.ID = wp_postmeta.post_id )
INNER JOIN wp_postmeta AS mt1
   ON ( wp_posts.ID = mt1.post_id )
INNER JOIN wp_postmeta AS mt2
   ON ( wp_posts.ID = mt2.post_id )
INNER JOIN wp_postmeta AS mt3
   ON ( wp_posts.ID = mt3.post_id )
INNER JOIN wp_postmeta AS mt4
   ON ( wp_posts.ID = mt4.post_id )
WHERE 1=1
AND ( ( wp_postmeta.meta_key = 'team' AND wp_postmeta.meta_value = 'polyglots' )
AND ( ( ( mt1.meta_key = 'recurring' AND mt1.meta_value NOT IN ('weekly','biweekly','occurrence','monthly','1') )
AND ( mt2.meta_key = 'start_date' AND CAST(mt2.meta_value AS DATE) >= CURDATE() ) )
OR ( ( mt3.meta_key = 'recurring'
AND mt3.meta_value IN ('weekly','biweekly','occurrence','monthly','1') )
AND ( ( mt4.meta_key = 'end_date' AND mt4.meta_value = '' )
OR ( mt4.meta_key = 'end_date' AND CAST(mt4.meta_value AS DATE) > CURDATE() ) ) ) ) )
AND wp_posts.post_type = 'meeting'
AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')
GROUP BY wp_posts.ID
ORDER BY wp_posts.post_date DESC

It'd probably be faster to just query all meeting entries and filter it in PHP...