SQL
AخA
SELECT r1.rev_id,
r1.rev_timestamp,
actor_name,
page_namespace, page_title,
r1.rev_len - COALESCE(r2.rev_len, 0) AS delta,
comment_text
FROM revision AS r1
JOIN comment_revision ON comment_id = r1.rev_comment_id
JOIN actor_revision ON actor_id = r1.rev_actor
JOIN page ON page_id = r1.rev_page
LEFT JOIN revision AS r2 ON r2.rev_id = r1.rev_parent_id
WHERE r1.rev_id IN
(
SELECT rev_id
FROM revision
JOIN comment_revision ON comment_id = rev_comment_id
WHERE comment_text LIKE '%ReferenceExpander%'
AND rev_timestamp BETWEEN '2020' AND '2021' -- any range longer than about a year does a full table scan
UNION
SELECT rev_id
FROM revision
JOIN comment_revision ON comment_id = rev_comment_id
WHERE comment_text LIKE '%ReferenceExpander%'
AND rev_timestamp BETWEEN '2021' AND '2022'
UNION
SELECT rev_id
FROM revision
JOIN comment_revision ON comment_id = rev_comment_id
WHERE comment_text LIKE '%ReferenceExpander%'
AND rev_timestamp BETWEEN '2022' AND '2023'
UNION
SELECT rev_id
FROM revision
JOIN comment_revision ON comment_id = rev_comment_id
WHERE comment_text LIKE '%ReferenceExpander%'
AND rev_timestamp >= '2023'
)
ORDER BY r1.rev_len - COALESCE(r2.rev_len, 0) ASC;
By running queries you agree to the Cloud Services Terms of Use and you irrevocably agree to release your SQL under CC0 License.
All SQL code is licensed under CC0 License.