Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iFcPf-000693-NP for pgsql-general@arkaria.postgresql.org; Wed, 02 Oct 2019 11:03:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iFcPe-0006pz-FX for pgsql-general@arkaria.postgresql.org; Wed, 02 Oct 2019 11:03:18 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iFcPd-0006pl-Vd for pgsql-general@lists.postgresql.org; Wed, 02 Oct 2019 11:03:18 +0000 Received: from mail-io1-xd41.google.com ([2607:f8b0:4864:20::d41]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iFcPb-0001Ei-En for pgsql-general@lists.postgresql.org; Wed, 02 Oct 2019 11:03:16 +0000 Received: by mail-io1-xd41.google.com with SMTP id q1so55908287ion.1 for ; Wed, 02 Oct 2019 04:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=YN8VkntbSaFjXL7VgLZleZDqzF3x2V+H5QL0xDr85lE=; b=nlWgDxxGtFJyDwnCRlX5d+sBm1ZY8BKKScRCIiTube8ubct5P+C1eZ8Mf4TjVyk+mE hTRvaP2f2UihbBQAmEXe4zf7a4JuZMpN2wk6RlJzON+ptkEK3HCoO1AM5Y/LA2URF0pe V0zQj3uzZEtdxFrIURxX2ZY84PKZsmzcN6mE5EjHnLW20KniFH8U0Cw1DaA1cihM5+/d 7wiFL8LPObSocUBfXjkK5lwmZ7tcIZ+JYquyv/zgIyOssm633l36ABrhGNXetkh+EB2Y KZHye4GeU8cAGKffRJeYJ3610HMvFScoa24z1X3hJNh0xpMXgpacWZVf02vgwRX8Yfkt FXrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=YN8VkntbSaFjXL7VgLZleZDqzF3x2V+H5QL0xDr85lE=; b=P8uQCUEw2C3jAHe9REf2d67KpUId+jopFCPikK3SZFDR1esCIWrNpR9wntlSSBoXpH 8JgpN+Mlcm7F239EK3fBppDb2GqZ9SGrqKRjW2Z9tN/6nLbii4M5J9qRq3CylfqSkD8U 6km44LIonyLJhysiPpKIwpn9wLtN+RQhMslA4vlpFAyrhaeKQLniZ6yVngS5qGbIq+S/ fExwLG/zm2ffedmVuB3Vs2k/DKM/N9nd69c5gomqv65k5fdPBo/JJ0QSiHkfL1lIZCCP nyHimntIcThMXOdsWnCMcgTbA/DCAKACIfRjhMaiHvFJLPnvvy7HdUeBUlBEj9P69Yd/ klCA== X-Gm-Message-State: APjAAAWrgtMUL9IiDA6AkqRsSs9MYYYbB22f0qNOeG8WWztsVWJQ3dE5 prRF8WlspvHLUhyg784UVL4= X-Google-Smtp-Source: APXvYqwfF5og3QY5SJXDN+p5NN+tJzL03ozdwA7aZOAHLGS7ppRoUYhORCScPP9THWwRTH1l42EOdA== X-Received: by 2002:a02:a808:: with SMTP id f8mr3332839jaj.42.1570014194292; Wed, 02 Oct 2019 04:03:14 -0700 (PDT) Received: from [10.0.0.10] (c-73-63-59-118.hsd1.ut.comcast.net. [73.63.59.118]) by smtp.gmail.com with ESMTPSA id t18sm7720185ilm.51.2019.10.02.04.03.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Oct 2019 04:03:13 -0700 (PDT) Content-Type: multipart/alternative; boundary=Apple-Mail-6C063ECA-58F2-4D62-82A1-138D149977B9 Mime-Version: 1.0 (1.0) Subject: Re: Users, Roles and Connection Pooling From: Rob Sargent X-Mailer: iPhone Mail (16G102) In-Reply-To: Date: Wed, 2 Oct 2019 05:03:06 -0600 Cc: Stephen Frost , Laurenz Albe , "pgsql-general@lists.postgresql.org" Content-Transfer-Encoding: 7bit Message-Id: <63F171A7-29B7-49B9-B0C3-EC1455510D1B@gmail.com> References: <0503910ff326d635e681849565de20db63c63eca.camel@cybertec.at> <20191002074310.GH6962@tamriel.snowman.net> To: Matt Andrews List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail-6C063ECA-58F2-4D62-82A1-138D149977B9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > On Oct 2, 2019, at 3:41 AM, Matt Andrews wrote= : >=20 > I have little experience in this area, but it seems like having a Postgres= role for every application user is the right way to do things. It=E2=80=99s= just that it also seems really inconvenient. >=20 > For example how to map an application=E2=80=99s users/people table to Post= gres roles? The pg_role name field is limited to 64 bytes, you can=E2=80=99t= create a foreign key to pg_role. What=E2=80=99s the answer? Use UUIDs as us= ernames or something? >=20 > There=E2=80=99s very little out there on this topic, but surely this has b= een done before.=20 >=20 >> On Wed, 2 Oct 2019 at 17:43, Stephen Frost wrote: >> Greetings, >>=20 >> * Laurenz Albe (laurenz.albe@cybertec.at) wrote: >> > A couple of pointers: >>=20 >> I generally agree with these comments. >>=20 >> > - This is a good setup if you don't have too many users. Metadata >> > queries will start getting slow if you get into the tens of thousands= >> > of users, maybe earlier. >>=20 >> While this seems plausible- I'd love to hear about exactly what you've >> seen start to be a problem when getting up to that many users. Are you >> just referring to things like \du? Or..? >>=20 >> Thanks, >>=20 >> Stephen The terminology gets a little wonky here since =E2=80=9Cuser=E2=80=9D equals= =E2=80=9Crole=E2=80=9D in postgres terms but I=E2=80=99ll apply user to the= person using your app.=20 What are your expected numbers of total distinct users?=20 Ratio of users to roles (as permissions set) or is every user unique in acce= ss needs? Do any users need to be in more than one role/group?=20 When/how will you assign role to user? I feel these issues will affect your choice of design.=20= --Apple-Mail-6C063ECA-58F2-4D62-82A1-138D149977B9 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

On Oct 2, 2019, at 3:41 AM, Matt Andrews <mattandrews@massey.com.au> w= rote:

I have little experience in this area, but it seems like having a Pos= tgres role for every application user is the right way to do things. It=E2=80= =99s just that it also seems really inconvenient.
For example how to map an application=E2=80=99s use= rs/people table to Postgres roles? The pg_role name field is limited to 64 b= ytes, you can=E2=80=99t create a foreign key to pg_role. What=E2=80=99s the a= nswer? Use UUIDs as usernames or something?

There=E2=80=99s very little out there on this topic, but s= urely this has been done before. 

<= div>On Wed, 2 Oct 2019 at 17:43, Stephen Frost <sfrost@snowman.net> wrote:
Greetings,

* Laurenz Albe (laurenz.albe@cybertec.at) wrote:
> A couple of pointers:

I generally agree with these comments.

> - This is a good setup if you don't have too many users.  Metadata=
>   queries will start getting slow if you get into the tens of= thousands
>   of users, maybe earlier.

While this seems plausible- I'd love to hear about exactly what you've
seen start to be a problem when getting up to that many users.  Are you=
just referring to things like \du?  Or..?

Thanks,

Stephen
The terminology g= ets a little wonky here since =E2=80=9Cuser=E2=80=9D equals =E2=80=9Crole=E2= =80=9D in postgres terms but I=E2=80=99ll apply user to the person using you= r app. 
What are your expected numbers of total distinct user= s? 
Ratio of users to roles (as permissions set) or is every u= ser unique in access needs?
Do any users need to be in more than o= ne role/group? 
When/how will you assign role to user?
<= div>I feel these issues will affect your choice of design. = --Apple-Mail-6C063ECA-58F2-4D62-82A1-138D149977B9--