Skip to content

Instantly share code, notes, and snippets.

@squadette
Last active June 14, 2018 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save squadette/a65b84807ceb78158b162da0fb67b37e to your computer and use it in GitHub Desktop.
Save squadette/a65b84807ceb78158b162da0fb67b37e to your computer and use it in GitHub Desktop.
CREATE TABLE `timeline_entries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`timeline_id` int(11) NOT NULL,
`post_id` int(11) NOT NULL,
`fresh_at` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_timeline_entries_on_post_id_and_timeline_id` (`post_id`,`timeline_id`) USING BTREE,
KEY `index_timeline_entries_on_timeline_id_and_created_at` (`timeline_id`,`created_at`) USING BTREE,
KEY `index_timeline_entries_on_timeline_id_and_fresh_at` (`timeline_id`,`fresh_at`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=151276917 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
SELECT `timeline_entries`.*
FROM `timeline_entries`
WHERE `timeline_entries`.`timeline_id` IN (<ids...>)
AND (`timeline_entries`.`post_id` NOT IN (
SELECT `timeline_entries`.`post_id` FROM `timeline_entries` WHERE `timeline_entries`.`timeline_id` = <id>)
)
ORDER BY `timeline_entries`.`fresh_at` DESC
LIMIT 151
OFFSET 450
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment