38 if ( !$this->getDB(
DB_PRIMARY )->tableExists(
'blob_orphans', __METHOD__ ) ) {
39 $this->fatalError(
"blob_orphans doesn't seem to exist, need to run trackBlobs.php first" );
41 $dbr = $this->getReplicaDB();
42 $res = $dbr->newSelectQueryBuilder()
44 ->from(
'blob_orphans' )
45 ->caller( __METHOD__ )->fetchResultSet();
52 foreach ( $res as $row ) {
53 $extDB = $this->getExternalDB(
DB_REPLICA, $row->bo_cluster );
54 $blobRow = $extDB->newSelectQueryBuilder()
57 ->where( [
'blob_id' => $row->bo_blob_id ] )
58 ->caller( __METHOD__ )->fetchRow();
61 $size = strlen( $blobRow->blob_text );
63 $hashes[sha1( $blobRow->blob_text )] =
true;
64 $maxSize = max( $size, $maxSize );
68 $this->output(
"Number of orphans: $num\n" );
70 $this->output(
"Average size: " . round( $totalSize / $num, 0 ) .
" bytes\n" .
71 "Max size: $maxSize\n" .
72 "Number of unique texts: " . count( $hashes ) .
"\n" );