Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE

From: Tom Lane
Subject: Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE
Date: ,
Msg-id: 6684.1512662473@sss.pgh.pa.us
(view: Whole thread, Raw)
In response to: Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE  (Ulf Lohbrügge)
Responses: Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE  (Ulf Lohbrügge)
List: pgsql-performance

Tree view

[PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE  (Ulf Lohbrügge, )
 Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE  (Tom Lane, )
  Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE  (Ulf Lohbrügge, )
 Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESETROLE  (Andres Freund, )
  Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE  (Ulf Lohbrügge, )
   Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE  (Scott Marlowe, )
    Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE  (Ulf Lohbrügge, )
 Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESETROLE  (Andres Freund, )
  Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE  (Ulf Lohbrügge, )
 Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE  (Ulf Lohbrügge, )
  Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE  (Tom Lane, )
   Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE  (Ulf Lohbrügge, )
    Re: [PERFORM] Slow execution of SET ROLE, SET search_path and RESET ROLE  (Tom Lane, )

=?UTF-8?Q?Ulf_Lohbr=C3=BCgge?= <> writes:
> I could reproduce part of the things I described earlier in this thread. A
> guy named Andriy Senyshyn mailed me after reading this thread here (he
> could somehow not join the mailing list) and observed a difference when
> issuing "SET ROLE" as user postgres and as a non-superuser.

This isn't particularly surprising in itself.  When we know that the
session user is a superuser, SET ROLE just succeeds immediately.
Otherwise we have to determine whether the SET is allowed, ie, is
the session user a member of the specified role.

It looks like the first time such a question is asked within a session,
we build and cache a list of all the roles the session user is a member
of (directly or indirectly).  That's what's taking the time here ---
apparently in your test case, the "admin" role is a member of a whole lot
of roles?

            regards, tom lane



pgsql-performance by date:

From: Claudio Freire
Date:
Subject: Re: pg_dump 3 times as slow after 8.4 -> 9.5 upgrade
From: Flávio Henrique
Date:
Subject: Learning EXPLAIN