pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tim Cross <theophilusx@gmail.com>
Cc: Olivier Gautherot <olivier@gautherot.net>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: space.ship.traveller@gmail.com
Cc: Postgres General <pgsql-general@postgresql.org>
Subject: Re: Safe operations?
Date: Sun, 12 Aug 2018 23:00:58 -0400
Message-ID: <11121.1534129258@sss.pgh.pa.us> (raw)
In-Reply-To: <CAC=50j8LNei-oP2GEFJjYS4N5jWugKm+utytjEMXY4W9mbZPVQ@mail.gmail.com>
References: <CAHkN8V--O-PMk2h5mEhiXvH3Wk2L6k4wzAzjHt5MC3XpiYj3Jg@mail.gmail.com>
	<dddf5f6d-9270-a64f-35c5-830c05aafd77@aklaver.com>
	<CAC=50j_B_XEiQED1N3W886FL2tL+RmNmTOruGUSxHmpVygaJDQ@mail.gmail.com>
	<CAJ7S9TVpS9xX1aTxWENZpWA-QO=DiN6cUPTz_Toc7yhPNZqzaA@mail.gmail.com>
	<CAC=50j8LNei-oP2GEFJjYS4N5jWugKm+utytjEMXY4W9mbZPVQ@mail.gmail.com>

Tim Cross <theophilusx@gmail.com> writes:
> On Mon, 13 Aug 2018 at 12:23, Olivier Gautherot <olivier@gautherot.net>
>> On Sun, Aug 12, 2018 at 11:06 PM, Tim Cross <theophilusx@gmail.com> wrote:
>>> Just wondering - what about the case when the column being renamed is
>>> also referenced in an index or check constraint?

>> Tim, as far as I know, names are only an attribute tagged to an OID.
>> Internal relations are though these OIDs, not names, so renaming a column
>> is really one-shot. Names are mainly a more convenient way of referring to
>> objects.

> thanks Olivier, that is what I suspected and your explanation fits with my
> mental model. I had assumed table/column names are convenience for humans
> and that the system would use OIDs etc for internal references.

Right, catalog internal references are all via OIDs or column numbers,
so that the only thing the system thinks it needs to do is update the
"name" field in a single catalog row.  (A problem with this is that
user-defined function bodies are stored as text; so you may well have
to run around and fix your functions by hand.  But that doesn't
contribute to the cost of the RENAME operation per se.)

Getting back to Samuel's original question, the reason we don't try
to document performance issues like this is that there are just too
many moving parts.  Yeah, the update of the catalog row should be
more or less O(1), and then the required updates of the catalog's
indexes will be more or less O(log N) (N being the number of rows
in that catalog).  But in practice the main constraint is often the
need to obtain locks on the relevant database objects, and that's
really hard to give a prediction for.

			regards, tom lane




view thread (7+ messages)  latest in thread

Message-ID: <11121.1534129258@sss.pgh.pa.us>
Permalink:  ../11121.1534129258@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/11121.1534129258@sss.pgh.pa.us

 · 

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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, theophilusx@gmail.com, olivier@gautherot.net, adrian.klaver@aklaver.com, space.ship.traveller@gmail.com
  Subject: Re: Safe operations?
  In-Reply-To: <11121.1534129258@sss.pgh.pa.us>
  References: <CAHkN8V--O-PMk2h5mEhiXvH3Wk2L6k4wzAzjHt5MC3XpiYj3Jg@mail.gmail.com> <dddf5f6d-9270-a64f-35c5-830c05aafd77@aklaver.com> <CAC=50j_B_XEiQED1N3W886FL2tL+RmNmTOruGUSxHmpVygaJDQ@mail.gmail.com> <CAJ7S9TVpS9xX1aTxWENZpWA-QO=DiN6cUPTz_Toc7yhPNZqzaA@mail.gmail.com> <CAC=50j8LNei-oP2GEFJjYS4N5jWugKm+utytjEMXY4W9mbZPVQ@mail.gmail.com> <11121.1534129258@sss.pgh.pa.us>

* 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