Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I would like to know how to get database data transfer stats in PostgreSQL and MySQL.

Like for example I need to know how many bytes are transfered per day/week/month.

Thanks in advance! Regards.

share|improve this question
    
For Postgres see here: postgresql.org/docs/current/static/monitoring-stats.html –  a_horse_with_no_name Jan 14 '14 at 17:13

1 Answer 1

up vote 3 down vote accepted

MySQL:

mysql> SHOW GLOBAL STATUS LIKE 'Bytes%';

This reports the total number of bytes sent and received since the last server restart.

Unfortunately, MySQL doesn't track per day/week/month subtotals. But you can estimate an average bytes per second by dividing these totals by another global status variable 'Uptime' which is the number of seconds since the last restart.

Another option is to use a monitoring tool that collects the status values at an interval and graphs them. For example Cacti is a popular open-source monitoring tool, and you can install MySQL-specific graphs. The best (free) ones are the Percona Monitoring Plugins for Cacti (disclaimer: I work for Percona).

PostgreSQL:

No tracking of bytes transferred is supported. I found a discussion thread about a proposed patch to add this capability, during October 2013, but I guess it hasn't become part of any released version of the product yet: http://postgresql.1045698.n5.nabble.com/stats-for-network-traffic-WIP-td5775200.html

General:

You can also use netstat or other tools outside of the MySQL/PostgreSQL to measure network activity.

share|improve this answer
    
Thank you very much! –  ipegasus Jan 14 '14 at 21:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.