Last active
November 1, 2016 14:32
-
-
Save vdubyna/6609575 to your computer and use it in GitHub Desktop.
Analize magento mysql log
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @author [email protected] | |
| */ | |
| $c = file_get_contents('pdo_mysql-2.log'); | |
| $qs = explode("\n\n", $c); | |
| array_pop($qs); | |
| $res = 0; | |
| $dups = array(); | |
| $tdups = array(); | |
| foreach ($qs as $q) { | |
| $q = explode("\n", $q); | |
| $t = explode(" ", end($q)); | |
| if (isset($dups[$q[2]])) { | |
| $dups[$q[2]] += 1; | |
| $tdups[$q[2]] += $t[1]; | |
| } else { | |
| $dups[$q[2]] = 1; | |
| $tdups[$q[2]] = $t[1]; | |
| } | |
| $res += $t[1]; | |
| } | |
| $rdups = array_filter($dups, function ($i) { return ($i > 1);} ); | |
| echo $res . PHP_EOL; | |
| foreach ($rdups as $k => $v) { | |
| echo str_pad($v, 5, " ") . " = " | |
| . str_pad($tdups[$k], 8, " ") | |
| . " =" . substr($k, 0 , 100) . "\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment