Обсуждение: Re: [BUGS] postgresql table data control
On Sat, Oct 17, 2015 at 1:26 AM, 許耀彰 <kpm906@gmail.com> wrote:
Dear Support Team,How can we know each table data increase day by day? It mean how do we get how many data produce today,included which data? Thank you.
[moving from bugs@]
Please refer to these SQL-level functions:
pg_relation_size()
pg_total_relation_size()
pg_size_pretty()
On Sat, Oct 17, 2015 at 1:26 AM, 許耀彰 <kpm906@gmail.com> wrote:Dear Support Team,How can we know each table data increase day by day? It mean how do we get how many data produce today,included which data? Thank you.[moving from bugs@]Please refer to these SQL-level functions:pg_relation_size()pg_total_relation_size()pg_size_pretty()
If you are looking to track this over time, you'll need to use a tool that is capturing this in snapshots and do some reporting over it.
I've written a script that I use frequently as part of my OpenWatch tool (https://bitbucket.org/scott_mead/openwatch/src/d024185b1b5585f7b4c8a5ad6b926eafed2e249e/bindings/java/sql/OpenWatch-Snapshots.sql?at=master&fileviewer=file-view-default). Run this script in the database, then run snapshots periodically:
Select snapshots.save_snap();
To see a size report between snapshots, list the available snapshots:
select * from list_snaps();
To get the size report, get the snap_id numbers you want to report between and run:
select * from snapshots.report_tables(<startsnapid>, <endsnapid>)
If you download the full OpenWatch tool (https://bitbucket.org/scott_mead/openwatch/downloads) and run it from the shell script, you an add cpu, disk/io and memory to the report as well.