List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:June 4 2005 2:42am
Subject:Re: SQL for performance statistics
View as plain text  
In the last episode (Jun 03), Ana Leite said:
> I'm new to MySQL and I'm trying to write a program that among other
> things monitors database usage. I would like to write an SQL query to
> retrieve info like session id, user name, cpu usage. Is there any
> MySQL system tables that gives me this sort of information?
>  
> To be more precise, I'm trying to get the MySQL equivalent of the
> following Oracle SQL:
>  
> select 
>    sesstat.sid as sid, 
>    sess.username user, 
>    sess.status as status, 
>    sess.program as program, 
>    aud.name as command, 
>    sesstat.value / 100 as cpu, 

Try "SHOW PROCESSLIST".  that will get you all the above info except
CPU usage.  You can't get that, since MySQL uses threads and getrusage
only gives you the process total.  Oracle creates a separate process
for each connection, which is why it can give you CPU.

-- 
	Dan Nelson
	dnelson@stripped
Thread
SQL for performance statisticsAna Leite4 Jun
  • Re: SQL for performance statisticsDan Nelson4 Jun