Too many rows in file_on

David Phillips david at acz.org
Thu Dec 7 04:14:40 UTC 2006


On 12/6/06, Andreas J. Koenig <andreas.koenig.gmwojprw at franz.ak.mind.de> wrote:
> Needless to say that plenty of records exist for which there is a
> file_on record but no file record.
>
> Is this perl script suited for cleaning up or are there nicer ways?

MySQL specific way:

DELETE file_on
FROM file_on
LEFT JOIN file USING (fid)
WHERE dkey IS NULL
;

Generic way (other databases don't require a temporary table):

CREATE TEMPORARY TABLE tmp AS
SELECT fid
FROM file_on
LEFT JOIN file USING (fid)
WHERE dkey IS NULL
;
DELETE FROM file_on WHERE fid NOT IN (SELECT fid FROM tmp);


More information about the mogilefs mailing list