pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Connection hangs on new created schema
3+ messages / 2 participants
[nested] [flat]

* Connection hangs on new created schema
@ 2018-03-27 21:46  Juan Manuel Cuello <juanmacuello@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Juan Manuel Cuello @ 2018-03-27 21:46 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

I have a postgresql database with around 4000 schemas. Each schema has
around the same 65 tables. There are 8 processes connected to the database
(it is a web app). Each process has only one direct connection to the
database (no connection pool).

Everything works ok until a new schema (with all its tables, indices, etc)
is added to the database. When this happens, the next query made to the
database takes too long, sometimes more than a minute o two. Also I see a
high DB CPU usage during that lapse. Then everything continues working ok
as usual and CPU drops to normal levels.

I'm mostly sure this has to do with the amount of schemas, maybe related to
relcache, but not sure why creating new schemas causes all this and where
to look to solve this problem.

i can see also the server hast a lot of free memory and is no swapping at
all.

OS: Linux
Server version: 9.3.20

Any insight will be highly appreciated.

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

* Re: Connection hangs on new created schema
@ 2018-03-28 05:58  Laurenz Albe <laurenz.albe@cybertec.at>
  parent: Juan Manuel Cuello <juanmacuello@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Laurenz Albe @ 2018-03-28 05:58 UTC (permalink / raw)
  To: Juan Manuel Cuello <juanmacuello@gmail.com>; pgsql-general@lists.postgresql.org

Juan Manuel Cuello wrote:
> I have a postgresql database with around 4000 schemas. Each schema has around
> the same 65 tables. There are 8 processes connected to the database (it is a web app).
> Each process has only one direct connection to the database (no connection pool).
> 
> Everything works ok until a new schema (with all its tables, indices, etc)
> is added to the database. When this happens, the next query made to the database
> takes too long, sometimes more than a minute o two. Also I see a high DB CPU usage
> during that lapse. Then everything continues working ok as usual and CPU drops to normal levels.
> 
> I'm mostly sure this has to do with the amount of schemas, maybe related to relcache,
> but not sure why creating new schemas causes all this and where to look to solve this problem.

If you know the slow query EXPLAIN (ANALYZE, BUFFERS) it and see where the time
is spent.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com




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

* Re: Connection hangs on new created schema
@ 2018-03-28 10:06  Juan Manuel Cuello <juanmacuello@gmail.com>
  parent: Laurenz Albe <laurenz.albe@cybertec.at>
  0 siblings, 0 replies; 3+ messages in thread

From: Juan Manuel Cuello @ 2018-03-28 10:06 UTC (permalink / raw)
  To: Laurenz Albe <laurenz.albe@cybertec.at>; +Cc: pgsql-general@lists.postgresql.org

On Wed, Mar 28, 2018 at 2:58 AM, Laurenz Albe <laurenz.albe@cybertec.at>
wrote:

> Juan Manuel Cuello wrote:
> > I have a postgresql database with around 4000 schemas. Each schema has
> around
> > the same 65 tables. There are 8 processes connected to the database (it
> is a web app).
> > Each process has only one direct connection to the database (no
> connection pool).
> >
> > Everything works ok until a new schema (with all its tables, indices,
> etc)
> > is added to the database. When this happens, the next query made to the
> database
> > takes too long, sometimes more than a minute o two. Also I see a high DB
> CPU usage
> > during that lapse. Then everything continues working ok as usual and CPU
> drops to normal levels.
> >
> > I'm mostly sure this has to do with the amount of schemas, maybe related
> to relcache,
> > but not sure why creating new schemas causes all this and where to look
> to solve this problem.
>
> If you know the slow query EXPLAIN (ANALYZE, BUFFERS) it and see where the
> time
> is spent.
>


I doesn't seem to depend on the query. Immediately after the new schema is
created, the next query takes a lot of time. It eventually resolves and
next statements are executed ok.

I think it is related to something the db processes are doing when the new
schema is created (maybe reloading relcache?), because the db processes
consumes a lot of CPU during that lapse. After a while, everything goes
back to normality.

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


end of thread, other threads:[~2018-03-28 10:06 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27 21:46 Connection hangs on new created schema Juan Manuel Cuello <juanmacuello@gmail.com>
2018-03-28 05:58 ` Laurenz Albe <laurenz.albe@cybertec.at>
2018-03-28 10:06   ` Juan Manuel Cuello <juanmacuello@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