pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: pgsql-hackers@postgresql.org
Subject: Re: [COMMITTERS] pgsql: Use a bitmask to represent role attributes
Date: Tue, 23 Dec 2014 10:34:47 -0500
Message-ID: <20141223153447.GD3062@tamriel.snowman.net> (raw)
In-Reply-To: <31247.1419347882@sss.pgh.pa.us>
References: <E1Y3PQG-0006Hc-Ff@gemulon.postgresql.org>
	<31247.1419347882@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

* Tom Lane (tgl@sss.pgh.pa.us) wrote:
> Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> > Use a bitmask to represent role attributes
> > The previous representation using a boolean column for each attribute
> > would not scale as well as we want to add further attributes.
> 
> > Extra auxilliary functions are added to go along with this change, to
> > make up for the lost convenience of access of the old representation.
> 
> I have to apologize for not having paid more attention, but ... is this
> *really* such a great idea?  You've just broken any client-side code
> that looks directly at pg_authid.

Anything which looks at pg_authid for the relevant columns needs to be
updated for the changes which were made for rolreplication previously,
and now rolbypassrls and any other role attributes added.  While I agree
that it's something to consider (and even mentioned it earlier in the
thread..), there wasn't any argument about it from those who were
following the discussion.

Perhaps we could have gone out of our way to ask the pgAdmin authors and
other client-side utilities which look at these columns if this will
more issues than new columns do.

> Moreover, I don't particularly buy
> the idea that this somehow insulates us from the compatibility costs of
> adding new role properties: you're still going to have to add columns to
> the pg_roles view, and adjust clients that look at that, every time.

That's correct, however, this change wasn't intended to insulate anyone
from those compatibility changes but rather to make better use of the
bytes in each pg_authid record.  We were already up to 8 individual bool
columns, wasting space for each.

> Replacing bool-column accesses with bitmask manipulation doesn't seem
> like it's a win on a micro-optimization level either, certainly not for
> SQL-level coding where you've probably made it two orders of magnitude
> more expensive.

I agree that it's more expensive for SQL users, but it's not our first
use of a bitmask in the catalog.  Perhaps this is more user-visible than
other use-cases but we also provide views to address common usages in
this case already, where we don't in other situations.

> And lastly, what happens when you run out of bits in
> that bigint column?

We can add another, though this seems unlikely to happen given the
previous discussion and review of what additional role attributes would
be nice to add.  There are some scenarios I've considered which would
lead to using perhaps another 15-20, but 64 sure seems far off.

> Again, I suppose I should have objected earlier, but I really seriously
> doubt that this is a good idea.

I tried to solicit discussion about these concerns earlier but we're all
busy, no problem.

For my 2c, I do think this is the right direction to go in as adding
another 15 boolean columns to pg_authid definitely strikes me as a bad
idea, but we can certainly discuss the trade-offs.  Another proposal
(from Simon, as I recall) was to use an array.  That runs into nearly
all the same problems and the on-disk representation ends up being even
larger, which is why I didn't see that being a good idea.

	Thanks,

		Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

view thread (27+ messages)  latest in thread

Message-ID: <20141223153447.GD3062@tamriel.snowman.net>
Permalink:  ../20141223153447.GD3062@tamriel.snowman.net/
Also on:    postgresql.org/message-id/20141223153447.GD3062@tamriel.snowman.net

 · 

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-committers@postgresql.org
  Cc: sfrost@snowman.net, tgl@sss.pgh.pa.us, alvherre@alvh.no-ip.org, pgsql-hackers@postgresql.org
  Subject: Re: [COMMITTERS] pgsql: Use a bitmask to represent role attributes
  In-Reply-To: <20141223153447.GD3062@tamriel.snowman.net>
  References: <E1Y3PQG-0006Hc-Ff@gemulon.postgresql.org> <31247.1419347882@sss.pgh.pa.us> <20141223153447.GD3062@tamriel.snowman.net>

* 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