From: Tim Starling Date: Fri, 19 Dec 2008 08:43:26 +0000 (+0000) Subject: Stats on the blob_orphans table, to make sure we're not losing anything by dropping... X-Git-Tag: 1.31.0-rc.0~43882 X-Git-Url: https://git.heureux-cyclage.org/w/index.php?a=commitdiff_plain;h=be768f01fd00f7e0c67997ae00aca116f2bf3ef2;p=lhc%2Fweb%2Fwiklou.git Stats on the blob_orphans table, to make sure we're not losing anything by dropping the tracked orphans. --- diff --git a/maintenance/storage/orphanStats.php b/maintenance/storage/orphanStats.php new file mode 100644 index 0000000000..77bf465d08 --- /dev/null +++ b/maintenance/storage/orphanStats.php @@ -0,0 +1,44 @@ +execute(); + +class OrphanStats { + function getDB( $cluster ) { + $lb = wfGetLBFactory()->getExternalLB( $cluster ); + return $lb->getConnection( DB_SLAVE ); + } + + function execute() { + $extDBs = array(); + $dbr = wfGetDB( DB_SLAVE ); + $res = $dbr->select( 'blob_orphans', '*', false, __METHOD__ ); + + $num = 0; + $totalSize = 0; + $hashes = array(); + $maxSize = 0; + + foreach ( $res as $boRow ) { + $extDB = $this->getDB( $boRow->bo_cluster ); + $blobRow = $extDB->selectRow( 'blobs', '*', array( 'blob_id' => $boRow->bo_blob_id ), __METHOD__ ); + + $num++; + $size = strlen( $blobRow->blob_text ); + $totalSize += $size; + $hashes[ sha1( $blobRow->blob_text ) ] = true; + $maxSize = max( $size, $maxSize ); + } + unset( $res ); + + echo "Number of orphans: $num\n" . + "Average size: " . round( $totalSize / $num, 0 ) . " bytes\n" . + "Max size: $maxSize\n" . + "Number of unique texts: " . count( $hashes ) . "\n"; + } +}