Skip to content

Instantly share code, notes, and snippets.

@danmactough
Created April 6, 2012 13:55
Show Gist options
  • Save danmactough/2319977 to your computer and use it in GitHub Desktop.
Save danmactough/2319977 to your computer and use it in GitHub Desktop.
Run daily to remove read posts older than 14 days
DELETE `posts`,`postmeta` FROM `posts` LEFT JOIN `postmeta` USING (`post_id`)
WHERE `postmeta_read` IS NULL OR
(`postmeta_read`=b'10'
AND `postmeta_liked`<1
AND `postmeta_starred`<1
AND `postmeta_shared`<1
AND DATEDIFF(CURDATE(),FROM_UNIXTIME(`posts`.`post_pubdate`)) > 14);
OPTIMIZE TABLE `posts`,`postmeta`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment