Manual talk:DeleteArchivedRevisions.php

From mediawiki.org
Latest comment: 10 years ago by Harry Wood in topic Equivalent SQL

Equivalent SQL[edit]

As the code looks currently, this script is pretty simple and I'm fairly confident that it is equivalent to running these two SQL queries. This may be handy for anyone without SSH access to a server.

/* Remove archived revisions, and permanently delete all deleted pages. */
DELETE FROM mw_archive;

/* Purge any text records which are not referenced from a revision record */
DELETE FROM mw_text WHERE old_id NOT IN (
   SELECT DISTINCT rev_text_id FROM mw_revision
);

Note that this can run very slowly. I set this running to remove tens of thousands of spam text records, and my server was hung for over an hour while it ran.

Actually the more complex purging process (the second query) is not really within this script class. This script just invokes function PurgeRedundantText in Maintenance.php [1] . This will actually check the archives table too, to avoid deleting text records referenced there. But since we know that this table is now empty, I've simplified the query a little. A more full SQL translation (which would run even slower) would be this:

/* Purge any text records which are not referenced from a revision or archive record */
DELETE FROM mw_text WHERE old_id NOT IN (
   SELECT DISTINCT rev_text_id FROM mw_revision
) AND old_id NOT IN (
   SELECT DISTINCT ar_text_id FROM mw_archive
)

Another alternative for people stuck with no SSH access . Extension:Maintenance or Extension:MaintenanceShell

-- Harry Wood (talk) 20:50, 7 October 2012 (UTC)Reply

Hello, Harry. I used the method proposed. The database tables were cleared, but it did not change anything. Deleted pages are still on the site. (MediaWiki 1.20.2) --AdSer8 (talk) 16:38, 20 November 2013 (UTC)Reply
These are pages which have been deleted by sysop delete action (Help:Sysop deleting and undeleting#Use the 'delete' action) correct? "Deleted pages are still on the site" what d'you mean by that exactly? -- Harry Wood (talk) 19:23, 20 November 2013 (UTC)Reply