pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Justin Pryzby <pryzby@telsasoft.com>
To: Lars Aksel Opsahl <Lars.Opsahl@nibio.no>
Cc: pgsql-performance@lists.postgresql.org
Subject: Re: slow "select count(*) from information_schema.tables;" in some cases
Date: Mon, 7 Feb 2022 11:09:27 -0600
Message-ID: <20220207170927.GF31460@telsasoft.com> (raw)
In-Reply-To: <AM7P189MB1028F684ADED9D89722C85C19D2C9@AM7P189MB1028.EURP189.PROD.OUTLOOK.COM>
References: <AM7P189MB1028F684ADED9D89722C85C19D2C9@AM7P189MB1028.EURP189.PROD.OUTLOOK.COM>

On Mon, Feb 07, 2022 at 04:56:35PM +0000, Lars Aksel Opsahl wrote:
> Sometimes simple sql's like this takes a very long time  "select count(*) from information_schema.tables;"
> 
> Other sql's not including system tables may work ok but login also takes a very long time.
> 
> The CPU load on the server is around 25%. There is no iowait.
> 
> This happens typically when we are running many functions in parallel creating many temp tables and unlogged tables I think.
> 
> Here is a slow one:
> https://explain.depesz.com/s/tUt5
> 
> and here is fast one :
> https://explain.depesz.com/s/yYG4

The only difference is that this is sometimes many times slower.

 Finalize Aggregate  (cost=42021.15..42021.16 rows=1 width=8) (actual time=50602.755..117201.768 rows=1 loops=1)
   ->  Gather  (cost=42020.94..42021.15 rows=2 width=8) (actual time=130.527..117201.754 rows=3 loops=1)
         Workers Planned: 2
         Workers Launched: 2

> Here are my settings (the server has around 256 GB og memory) :

What version of postgres ?  What OS/version ?
https://wiki.postgresql.org/wiki/Slow_Query_Questions

Are there any server logs around that time ?
Or session logs for the slow query ?

Is it because the table creation is locking (rows of) various system catalogs ?
I'm not sure if it'd be a single, long delay that you could see easily with
log_lock_waits, or a large number of small delays, maybe depending on whether
your table creation is done within a transaction.

-- 
Justin





view thread (9+ messages)  latest in thread

Message-ID: <20220207170927.GF31460@telsasoft.com>
Permalink:  ../20220207170927.GF31460@telsasoft.com/
Also on:    postgresql.org/message-id/20220207170927.GF31460@telsasoft.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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: pryzby@telsasoft.com, Lars.Opsahl@nibio.no, pgsql-performance@lists.postgresql.org
  Subject: Re: slow "select count(*) from information_schema.tables;" in some cases
  In-Reply-To: <20220207170927.GF31460@telsasoft.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