pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: PegoraroF10 <marcos@f10.com.br>
To: pgsql-general@postgresql.org
Subject: Re: slow queries on system tables
Date: Fri, 23 Aug 2019 16:12:22 -0700
Message-ID: <fb39831e-9ac7-316f-5acc-a594f4feef80@aklaver.com> (raw)
In-Reply-To: <1566600424403-0.post@n3.nabble.com>
References: <1565879436637-0.post@n3.nabble.com>
	<CAHOFxGrV0dj+4=s5-0-XG36_13t3smhKq0hujmRNaKqtfZ3YuA@mail.gmail.com>
	<1565896167022-0.post@n3.nabble.com>
	<88609b1c-1653-6d4c-c1b4-883e109f5b93@aklaver.com>
	<1565963536657-0.post@n3.nabble.com>
	<19659.1565966519@sss.pgh.pa.us>
	<1565968275886-0.post@n3.nabble.com>
	<1566596875387-0.post@n3.nabble.com>
	<0eca5ab6-82cf-9768-6f09-0cb9998a1fdf@aklaver.com>
	<1566600424403-0.post@n3.nabble.com>

On 8/23/19 3:47 PM, PegoraroF10 wrote:
> This week we added just 5 new customers. Every schema has 100 tables, 300
> indices, 400 triggers.
> I cannot imagine our script doing 75000 updates just for adding those
> schemas.

Very rough calculation:

https://www.postgresql.org/docs/11/catalog-pg-class.html

The catalog pg_class catalogs tables and most everything else that has 
columns or is otherwise similar to a table. This includes indexes (but 
see also pg_index), sequences (but see also pg_sequence), views, 
materialized views, composite types, and TOAST tables; see relkind. ...


 From above, not counting TOAST tables:

5 * (100 + 300) = 2,000 new entries.

 From previous post you said you had 190 schemas at that time.

190 * 400 = 76,000 entries
         +    2,000
             78,000

In pg_class rel* fields:

"It is updated by VACUUM, ANALYZE, and a few DDL commands such as CREATE 
INDEX."

Assuming tables/indexes have changed enough to trigger vacuum run:

78,000 * 1 vacuum = 78,000 updates



> 
> 
> 
> 
> --
> Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html
> 
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (16+ messages)  latest in thread

Message-ID: <fb39831e-9ac7-316f-5acc-a594f4feef80@aklaver.com>
Permalink:  ../fb39831e-9ac7-316f-5acc-a594f4feef80@aklaver.com/
Also on:    postgresql.org/message-id/fb39831e-9ac7-316f-5acc-a594f4feef80@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, marcos@f10.com.br
  Subject: Re: slow queries on system tables
  In-Reply-To: <fb39831e-9ac7-316f-5acc-a594f4feef80@aklaver.com>
  References: <1565879436637-0.post@n3.nabble.com> <CAHOFxGrV0dj+4=s5-0-XG36_13t3smhKq0hujmRNaKqtfZ3YuA@mail.gmail.com> <1565896167022-0.post@n3.nabble.com> <88609b1c-1653-6d4c-c1b4-883e109f5b93@aklaver.com> <1565963536657-0.post@n3.nabble.com> <19659.1565966519@sss.pgh.pa.us> <1565968275886-0.post@n3.nabble.com> <1566596875387-0.post@n3.nabble.com> <0eca5ab6-82cf-9768-6f09-0cb9998a1fdf@aklaver.com> <1566600424403-0.post@n3.nabble.com> <fb39831e-9ac7-316f-5acc-a594f4feef80@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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