Search code examples
mysqlphpmyadminmysql-workbenchworkbench

workbench and phpmyadmin are showing different number of connections


I am running mysql 8.0 on centos 7.4

phpmyadmin and workbench are showing totally different information regarding the number of connections (shown below). connections from phpmyadmin

at the sametime this is what I am seeing on workbench:

connections from workbench

This is what is being shown from inside phpmyadmin regarding the processes:

processes from inside phpmyadmin

The processes from inside workbench are shown below AND they coincide with the processes from phpmyadmin.

enter image description here

So why are they showing the same of processes but very different number of connections?


Solution

  • If you look at the payload for the ajax requests you can see the requiredData, something like:

    {
        "0":[
            [{"type":"statusvar","name":"Questions"}]
        ],
        "1":[
            [{"type":"statusvar","name":"Connections"}],
            [{"type":"proc","name":"processes"}]
        ],
        "2":[
            [{"type":"statusvar","name":"Bytes_sent"}],
            [{"type":"statusvar","name":"Bytes_received"}]
        ],
        "3":[
            [{"type":"cpu","name":"loadavg"}]
        ],
        "4":[
            [{"type":"memory","name":"MemUsed"}],
            [{"type":"memory","name":"MemFree"}]
        ],
        "5":[
            [{"type":"memory","name":"SwapUsed"}],
            [{"type":"memory","name":"SwapFree"}]
        ]
    }
    

    The vars listed with "type":"statusvar" are retrieved using SHOW GLOBAL STATUS WHERE Variable_name=..., as can be seen here in Server/Status/Monitor.php:

    // Retrieve all required status variables
    $statusVarValues = [];
    if (count($statusVars)) {
        $statusVarValues = $this->dbi->fetchResult(
            "SHOW GLOBAL STATUS WHERE Variable_name='"
            . implode("' OR Variable_name='", $statusVars) . "'",
            0,
            1
        );
    }
    

    If you look at refreshChartGrid() you can see that PMA is comparing the values received in each ajax call with the values from the previous call. For connections it is using the value of Connections, not Threads_connected which is used by Workbench.