4 * Show some statistics on the blob_orphans table, created with trackBlobs.php
6 require_once( dirname(__FILE__
).'/../commandLine.inc' );
8 $stats = new OrphanStats
;
12 function getDB( $cluster ) {
13 $lb = wfGetLBFactory()->getExternalLB( $cluster );
14 return $lb->getConnection( DB_SLAVE
);
19 $dbr = wfGetDB( DB_SLAVE
);
20 $res = $dbr->select( 'blob_orphans', '*', false, __METHOD__
);
27 foreach ( $res as $boRow ) {
28 $extDB = $this->getDB( $boRow->bo_cluster
);
29 $blobRow = $extDB->selectRow( 'blobs', '*', array( 'blob_id' => $boRow->bo_blob_id
), __METHOD__
);
32 $size = strlen( $blobRow->blob_text
);
34 $hashes[ sha1( $blobRow->blob_text
) ] = true;
35 $maxSize = max( $size, $maxSize );
39 echo "Number of orphans: $num\n" .
40 "Average size: " . round( $totalSize / $num, 0 ) . " bytes\n" .
41 "Max size: $maxSize\n" .
42 "Number of unique texts: " . count( $hashes ) . "\n";