Index: trunk/phase3/maintenance/storage/orphanStats.php |
— | — | @@ -0,0 +1,44 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Show some statistics on the blob_orphans table, created with trackBlobs.php |
| 6 | + */ |
| 7 | +require_once( dirname(__FILE__).'/../commandLine.inc' ); |
| 8 | + |
| 9 | +$stats = new OrphanStats; |
| 10 | +$stats->execute(); |
| 11 | + |
| 12 | +class OrphanStats { |
| 13 | + function getDB( $cluster ) { |
| 14 | + $lb = wfGetLBFactory()->getExternalLB( $cluster ); |
| 15 | + return $lb->getConnection( DB_SLAVE ); |
| 16 | + } |
| 17 | + |
| 18 | + function execute() { |
| 19 | + $extDBs = array(); |
| 20 | + $dbr = wfGetDB( DB_SLAVE ); |
| 21 | + $res = $dbr->select( 'blob_orphans', '*', false, __METHOD__ ); |
| 22 | + |
| 23 | + $num = 0; |
| 24 | + $totalSize = 0; |
| 25 | + $hashes = array(); |
| 26 | + $maxSize = 0; |
| 27 | + |
| 28 | + foreach ( $res as $boRow ) { |
| 29 | + $extDB = $this->getDB( $boRow->bo_cluster ); |
| 30 | + $blobRow = $extDB->selectRow( 'blobs', '*', array( 'blob_id' => $boRow->bo_blob_id ), __METHOD__ ); |
| 31 | + |
| 32 | + $num++; |
| 33 | + $size = strlen( $blobRow->blob_text ); |
| 34 | + $totalSize += $size; |
| 35 | + $hashes[ sha1( $blobRow->blob_text ) ] = true; |
| 36 | + $maxSize = max( $size, $maxSize ); |
| 37 | + } |
| 38 | + unset( $res ); |
| 39 | + |
| 40 | + echo "Number of orphans: $num\n" . |
| 41 | + "Average size: " . round( $totalSize / $num, 0 ) . " bytes\n" . |
| 42 | + "Max size: $maxSize\n" . |
| 43 | + "Number of unique texts: " . count( $hashes ) . "\n"; |
| 44 | + } |
| 45 | +} |
Property changes on: trunk/phase3/maintenance/storage/orphanStats.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 46 | + native |