pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to find the hits on the databases and tables in Postgres
8+ messages / 6 participants
[nested] [flat]

* How to find the hits on the databases and tables in Postgres
@ 2018-05-04 11:44 nikhil raj <nikhilraj474@gmail.com>
  2018-05-04 13:21 ` Re: How to find the hits on the databases and tables in Postgres Adrian Klaver <adrian.klaver@aklaver.com>
  2018-05-05 11:03 ` Re: How to find the hits on the databases and tables in Postgres PT <wmoran@potentialtech.com>
  0 siblings, 2 replies; 8+ messages in thread

From: nikhil raj @ 2018-05-04 11:44 UTC (permalink / raw)
  To: pgsql-general; pgsql-admin@postgresql.com; k.knizhnik@postgrespro.ru

 Hi,
Any one can please help me out

How to monitor the Hits on database and how many hits on each user tables
Through query.
Is there any other tools for that so it can full fill my requirement for it
.

Thanks,

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: How to find the hits on the databases and tables in Postgres
  2018-05-04 11:44 How to find the hits on the databases and tables in Postgres nikhil raj <nikhilraj474@gmail.com>
@ 2018-05-04 13:21 ` Adrian Klaver <adrian.klaver@aklaver.com>
  2018-05-04 16:45   ` Re: How to find the hits on the databases and tables in Postgres nikhil raj <nikhilraj474@gmail.com>
  1 sibling, 1 reply; 8+ messages in thread

From: Adrian Klaver @ 2018-05-04 13:21 UTC (permalink / raw)
  To: nikhil raj <nikhilraj474@gmail.com>; pgsql-general; pgsql-admin@postgresql.com; k.knizhnik@postgrespro.ru

On 05/04/2018 04:44 AM, nikhil raj wrote:
> Hi,
> Any one can please help me out
> 
> How to monitor the Hits on database and how many hits on each user 
> tables  Through query.
> Is there any other tools for that so it can full fill my requirement for 
> it .

https://www.postgresql.org/docs/10/static/monitoring-stats.html

https://www.postgresql.org/docs/10/static/monitoring-stats.html#PG-STAT-DATABASE-VIEW

https://www.postgresql.org/docs/10/static/monitoring-stats.html#PG-STAT-DATABASE-VIEW

pg_stat_user_tables Same as pg_stat_all_tables, except that only user 
tables are shown.

> 
> Thanks,
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: How to find the hits on the databases and tables in Postgres
  2018-05-04 11:44 How to find the hits on the databases and tables in Postgres nikhil raj <nikhilraj474@gmail.com>
  2018-05-04 13:21 ` Re: How to find the hits on the databases and tables in Postgres Adrian Klaver <adrian.klaver@aklaver.com>
@ 2018-05-04 16:45   ` nikhil raj <nikhilraj474@gmail.com>
  2018-05-04 18:36     ` Re: How to find the hits on the databases and tables in Postgres Adrian Klaver <adrian.klaver@aklaver.com>
  2018-05-04 20:22     ` Re: How to find the hits on the databases and tables in Postgres Thomas Kellerer <spam_eater@gmx.net>
  0 siblings, 2 replies; 8+ messages in thread

From: nikhil raj @ 2018-05-04 16:45 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-general; pgsql-admin@postgresql.com; k.knizhnik@postgrespro.ru

Hi Adrian Klaver,

Thanks for the fast response .

But here is the issue is here we have 200+ databases and 5 servers so
cannot manually runs this command all ways is there any 3rd party tool for
that which would give me the hits on DB and tables in it  so that it would
be so help full for me.

now currently prepared a scripts for that which goes and does for DB butr
after that i have much manually work with it so is there any third party
tool for that

Thanks,

On Fri, May 4, 2018 at 6:51 PM, Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

> On 05/04/2018 04:44 AM, nikhil raj wrote:
>
>> Hi,
>> Any one can please help me out
>>
>> How to monitor the Hits on database and how many hits on each user
>> tables  Through query.
>> Is there any other tools for that so it can full fill my requirement for
>> it .
>>
>
> https://www.postgresql.org/docs/10/static/monitoring-stats.html
>
> https://www.postgresql.org/docs/10/static/monitoring-stats.
> html#PG-STAT-DATABASE-VIEW
>
> https://www.postgresql.org/docs/10/static/monitoring-stats.
> html#PG-STAT-DATABASE-VIEW
>
> pg_stat_user_tables Same as pg_stat_all_tables, except that only user
> tables are shown.
>
>
>> Thanks,
>>
>>
>>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
>

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: How to find the hits on the databases and tables in Postgres
  2018-05-04 11:44 How to find the hits on the databases and tables in Postgres nikhil raj <nikhilraj474@gmail.com>
  2018-05-04 13:21 ` Re: How to find the hits on the databases and tables in Postgres Adrian Klaver <adrian.klaver@aklaver.com>
  2018-05-04 16:45   ` Re: How to find the hits on the databases and tables in Postgres nikhil raj <nikhilraj474@gmail.com>
@ 2018-05-04 18:36     ` Adrian Klaver <adrian.klaver@aklaver.com>
  1 sibling, 0 replies; 8+ messages in thread

From: Adrian Klaver @ 2018-05-04 18:36 UTC (permalink / raw)
  To: nikhil raj <nikhilraj474@gmail.com>; +Cc: pgsql-general; pgsql-admin@postgresql.com; k.knizhnik@postgrespro.ru

On 05/04/2018 09:45 AM, nikhil raj wrote:
> Hi Adrian Klaver,
> 
> Thanks for the fast response .
> 
> But here is the issue is here we have 200+ databases and 5 servers so 
> cannot manually runs this command all ways is there any 3rd party tool 
> for that which would give me the hits on DB and tables in it  so that it 
> would be so help full for me.
> 
> now currently prepared a scripts for that which goes and does for DB 
> butr after that i have much manually work with it so is there any third 
> party tool for that

The best I can do is point you at:

https://www.postgresql.org/download/products/5-reporting-tools/

Others on the list may be able to provide more information.

> 
> Thanks,
> 



-- 
Adrian Klaver
adrian.klaver@aklaver.com




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: How to find the hits on the databases and tables in Postgres
  2018-05-04 11:44 How to find the hits on the databases and tables in Postgres nikhil raj <nikhilraj474@gmail.com>
  2018-05-04 13:21 ` Re: How to find the hits on the databases and tables in Postgres Adrian Klaver <adrian.klaver@aklaver.com>
  2018-05-04 16:45   ` Re: How to find the hits on the databases and tables in Postgres nikhil raj <nikhilraj474@gmail.com>
@ 2018-05-04 20:22     ` Thomas Kellerer <spam_eater@gmx.net>
  1 sibling, 0 replies; 8+ messages in thread

From: Thomas Kellerer @ 2018-05-04 20:22 UTC (permalink / raw)
  To: pgsql-general

nikhil raj schrieb am 04.05.2018 um 18:45:
> But here is the issue is here we have 200+ databases and 5 servers so
> cannot manually runs this command all ways is there any 3rd party
> tool for that which would give me the hits on DB and tables in it  so
> that it would be so help full for me.
> 
> now currently prepared a scripts for that which goes and does for DB
> butr after that i have much manually work with it so is there any
> third party tool for that


Have a look at

* http://dalibo.github.io/powa/
* http://opm.io/





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: How to find the hits on the databases and tables in Postgres
  2018-05-04 11:44 How to find the hits on the databases and tables in Postgres nikhil raj <nikhilraj474@gmail.com>
@ 2018-05-05 11:03 ` PT <wmoran@potentialtech.com>
  2018-05-05 12:13   ` Re: How to find the hits on the databases and tables in Postgres Pavel Stehule <pavel.stehule@gmail.com>
  1 sibling, 1 reply; 8+ messages in thread

From: PT @ 2018-05-05 11:03 UTC (permalink / raw)
  To: nikhil raj <nikhilraj474@gmail.com>; +Cc: pgsql-general; pgsql-admin@postgresql.com; k.knizhnik@postgrespro.ru

On Fri, 4 May 2018 17:14:39 +0530
nikhil raj <nikhilraj474@gmail.com> wrote:

>  Hi,
> Any one can please help me out
> 
> How to monitor the Hits on database and how many hits on each user tables
> Through query.
> Is there any other tools for that so it can full fill my requirement for it

pgBadger has always been my goto tool for that: https://github.com/dalibo/pgbadger

-- 
Bill Moran <wmoran@potentialtech.com>




^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: How to find the hits on the databases and tables in Postgres
  2018-05-04 11:44 How to find the hits on the databases and tables in Postgres nikhil raj <nikhilraj474@gmail.com>
  2018-05-05 11:03 ` Re: How to find the hits on the databases and tables in Postgres PT <wmoran@potentialtech.com>
@ 2018-05-05 12:13   ` Pavel Stehule <pavel.stehule@gmail.com>
  2018-05-05 14:47     ` Re: How to find the hits on the databases and tables in Postgres Melvin Davidson <melvin6925@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Pavel Stehule @ 2018-05-05 12:13 UTC (permalink / raw)
  To: PT <wmoran@potentialtech.com>; +Cc: nikhil raj <nikhilraj474@gmail.com>; pgsql-general; pgsql-admin@postgresql.com; Konstantin Knizhnik <k.knizhnik@postgrespro.ru>

2018-05-05 13:03 GMT+02:00 PT <wmoran@potentialtech.com>:

> On Fri, 4 May 2018 17:14:39 +0530
> nikhil raj <nikhilraj474@gmail.com> wrote:
>
> >  Hi,
> > Any one can please help me out
> >
> > How to monitor the Hits on database and how many hits on each user tables
> > Through query.
> > Is there any other tools for that so it can full fill my requirement for
> it
>
> pgBadger has always been my goto tool for that: https://github.com/dalibo/
> pgbadger
>
>
There are some statistic per tables: .. select * from pg_stat_user_tables,
indexes: select * from pg_stat_user_indexes, and databases: select * from
pg_stat_database;

Regards

Pavel

-- 
> Bill Moran <wmoran@potentialtech.com>
>
>

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: How to find the hits on the databases and tables in Postgres
  2018-05-04 11:44 How to find the hits on the databases and tables in Postgres nikhil raj <nikhilraj474@gmail.com>
  2018-05-05 11:03 ` Re: How to find the hits on the databases and tables in Postgres PT <wmoran@potentialtech.com>
  2018-05-05 12:13   ` Re: How to find the hits on the databases and tables in Postgres Pavel Stehule <pavel.stehule@gmail.com>
@ 2018-05-05 14:47     ` Melvin Davidson <melvin6925@gmail.com>
  0 siblings, 0 replies; 8+ messages in thread

From: Melvin Davidson @ 2018-05-05 14:47 UTC (permalink / raw)
  To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: PT <wmoran@potentialtech.com>; nikhil raj <nikhilraj474@gmail.com>; pgsql-general; pgsql-admin@postgresql.com; Konstantin Knizhnik <k.knizhnik@postgrespro.ru>

 >How to monitor the Hits on database and how many hits on each user tables
> Through query.


*Do these help? You can run them through a cron job.*

*-- For all databases*














*SELECT pg_stat_database.datname,        pg_stat_database.blks_read,
pg_stat_database.blks_hit,        round((pg_stat_database.blks_hit::double
precision               / (pg_stat_database.blks_read                  +
pg_stat_database.blks_hit                  +1)::double precision *
100::double precision)::numeric, 2) AS cachehitratio   FROM
pg_stat_database  WHERE pg_stat_database.datname !~
'^(template(0|1)|postgres)$'::text  ORDER BY
round((pg_stat_database.blks_hit::double precision                  /
(pg_stat_database.blks_read                     + pg_stat_database.blks_hit
                    + 1)::double precision * 100::double
precision)::numeric, 2) DESC;*

*-- For all tables in a specific database (you need to iterate through all
db's)*





















*SELECT n.nspname,       s.relname,       c.reltuples::bigint,
c.relfrozenxid,       age(c.relfrozenxid) AS age_frozenxid,
n_live_tup,       n_tup_ins,       n_tup_upd,       n_tup_del,
date_trunc('second', last_vacuum) as last_vacuum,
date_trunc('second', last_autovacuum) as last_autovacuum,
date_trunc('second', last_analyze) as last_analyze,
date_trunc('second', last_autoanalyze) as last_autoanalyze ,       round(
current_setting('autovacuum_vacuum_threshold')::integer +
current_setting('autovacuum_vacuum_scale_factor')::numeric * C.reltuples)
AS av_threshold        ,CASE WHEN reltuples > 0              THEN
round(100.0 * n_dead_tup / (reltuples))            ELSE 0       END AS
pct_dead,       CASE WHEN n_dead_tup > round(
current_setting('autovacuum_vacuum_threshold')::integer +
current_setting('autovacuum_vacuum_scale_factor')::numeric * C.reltuples)
              THEN 'VACUUM'            ELSE 'ok'         END AS "av_needed"*






*  FROM pg_stat_all_tables s  JOIN pg_class c ON c.oid = s.relid  JOIN
pg_namespace n ON (n.oid = c.relnamespace) WHERE s.relname NOT LIKE
'pg_%'   AND s.relname NOT LIKE 'sql_%' ORDER by 1, 2;*

On Sat, May 5, 2018 at 8:13 AM, Pavel Stehule <pavel.stehule@gmail.com>
wrote:

>
>
> 2018-05-05 13:03 GMT+02:00 PT <wmoran@potentialtech.com>:
>
>> On Fri, 4 May 2018 17:14:39 +0530
>> nikhil raj <nikhilraj474@gmail.com> wrote:
>>
>> >  Hi,
>> > Any one can please help me out
>> >
>> > How to monitor the Hits on database and how many hits on each user
>> tables
>> > Through query.
>> > Is there any other tools for that so it can full fill my requirement
>> for it
>>
>> pgBadger has always been my goto tool for that:
>> https://github.com/dalibo/pgbadger
>>
>>
> There are some statistic per tables: .. select * from pg_stat_user_tables,
> indexes: select * from pg_stat_user_indexes, and databases: select * from
> pg_stat_database;
>
> Regards
>
> Pavel
>
> --
>> Bill Moran <wmoran@potentialtech.com>
>>
>>
>


-- 
*Melvin Davidson*
*Maj. Database & Exploration Specialist*
*Universe Exploration Command – UXC*
Employment by invitation only!

^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2018-05-05 14:47 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-05-04 11:44 How to find the hits on the databases and tables in Postgres nikhil raj <nikhilraj474@gmail.com>
2018-05-04 13:21 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-05-04 16:45   ` nikhil raj <nikhilraj474@gmail.com>
2018-05-04 18:36     ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-05-04 20:22     ` Thomas Kellerer <spam_eater@gmx.net>
2018-05-05 11:03 ` PT <wmoran@potentialtech.com>
2018-05-05 12:13   ` Pavel Stehule <pavel.stehule@gmail.com>
2018-05-05 14:47     ` Melvin Davidson <melvin6925@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox