Fork of
Highest edit count (enwiki, last 365 days)
by Chlod
This query is marked as a draft
This query has been published
by Cryptic.
SQL
x
-- start time
SET @tim = DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -1 DAY), "%Y%m%d%H%i%s");
-- Find the lowest rev_id with a timestamp >= that.
-- While revision.rev_id is in ascending order by rev_timestamp, the db
-- doesn't know that; if we just look for rev_timestamp >= @tim, then it
-- looks at *all* rows from then up until now, which takes nearly as
-- long as fetching the data we actually want.
-- So instead look for lowest rev_id within ten seconds starting from
-- the start time, which will be nearly instant. On enwiki, at least,
-- there's pretty much guaranteed to have been an edit in this long.
-- (But display the found rev_id afterwards anyway, just in case there
-- wasn't.)
SET @rev = (SELECT MIN(rev_id)
FROM revision
WHERE rev_timestamp BETWEEN @tim AND @tim + 10);
SELECT rev_id, rev_timestamp FROM revision WHERE rev_id = @rev;
SELECT COUNT(*) AS 'Edits',
actor_name
FROM revision_userindex
JOIN actor_revision ON rev_actor = actor_id
WHERE rev_id >= @rev
GROUP BY actor_name
ORDER BY COUNT(*) DESC
LIMIT 20;
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.