postgresql table data control

Started by 許耀彰over 10 years ago3 messagesbugsgeneral
Jump to latest
#1許耀彰
kpm906@gmail.com
bugsgeneral

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.

#2Shulgin, Oleksandr
oleksandr.shulgin@zalando.de
In reply to: 許耀彰 (#1)
bugsgeneral
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()

http://www.postgresql.org/docs/current/static/functions-admin.html

#3Scott Mead
scottm@openscg.com
In reply to: Shulgin, Oleksandr (#2)
bugsgeneral
Re: [BUGS] postgresql table data control

On Oct 19, 2015, at 04:29, Shulgin, Oleksandr <oleksandr.shulgin@zalando.de> wrote:

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&amp;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.

Show quoted text

http://www.postgresql.org/docs/current/static/functions-admin.html