pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Johnston <polobo@yahoo.com>
To: pgsql-bugs@postgresql.org
Subject: Re: BUG #9606: pg_class relhaspkey column not updated on removal of primary key
Date: Mon, 17 Mar 2014 21:24:24 -0700 (PDT)
Message-ID: <1395116664140-5796526.post@n5.nabble.com> (raw)
In-Reply-To: <CAHBAh5sd9BK=7qfjTDYBLSAtBh78rtnMSaGFoyfOb2S29FDxoQ@mail.gmail.com>
References: <20140317185255.20724.49675@wrigleys.postgresql.org>
	<25726.1395082770@sss.pgh.pa.us>
	<7FBC4B95-6AF6-4CFC-A4E2-DE7D9C30AB4B@pgexperts.com>
	<D0A66CF0-AD34-4647-9C05-1317ECFB97DC@pgexperts.com>
	<14341.1395105679@sss.pgh.pa.us>
	<CAHBAh5sd9BK=7qfjTDYBLSAtBh78rtnMSaGFoyfOb2S29FDxoQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Venkata Balaji Nagothi wrote
> On Tue, Mar 18, 2014 at 12:21 PM, Tom Lane &lt;

> tgl@.pa

> &gt; wrote:
> 
>> Jeff Frost &lt;

> jeff@

> &gt; writes:
>> > Interestingly, on 9.1.11, I have a table where the pkey was added after
>> the fact, then dropped, but it still shows as relhaspkey even though I
>> manually vacuumed it:
>>
>> IIRC, VACUUM only clears relhaspkey if there are *no* indexes left --- it
>> doesn't bother to check whether there's one calling itself indisprimary.
>> We could possibly change that but it's not clear that it's worth any
>> effort, given that the column would still have to be defined the same
>> way.
> 
> 
> Apologies if i am jumping into the conversation.
> 
> Technically, there is no harm or it does not make any big impact if
> "relhaspkey" column shows "t" even after the column has primary key
> constraint disabled.
> 
> Logically, the information in pg_class table can be mis-leading when the
> column is not behaving like a traditional "primary key column". I think,
> It
> is important that, the information showing up in the "relhaspkey" column
> must be based on the "primary key constraint" existence rather than the
> "Index existence".

The field in question is a table flag.  If you really care you have to query
the actual indexes for the current reality.  Unless it is false, it seems,
in which case you can skip the check.

As to Tom's "defined the same way" - does it truly mean "has index" or is it
"has unique index defined as primary"?  I ask because depending on how the
data is being used it may be worth it to a caller to force the flag to be
the correct value to avoid subsequent checks.  This only works when you
force it to false since adding an index will make it true while removing one
will go unnoticed.  But if the definition doesn't change even if you can
reset the flag while non-primary indexes are present then I am confused as
to why.

At the moment it's a solution waiting for a problem...and removing a primary
index would seem to be infrequent enough to not worry about.

It could be fixed but doing so for the sake of information perfection is a
tough sell to others.  Causing a performance regression makes it that much
tougher.  Thus someone with a pressing need and an elegant solution is
needed to get this changed.  Imperfect data in time is better than perfect
data too late.

David J.





--
View this message in context: http://postgresql.1045698.n5.nabble.com/BUG-9606-pg-class-relhaspkey-column-not-updated-on-removal-o...
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (9+ messages)  latest in thread

Message-ID: <1395116664140-5796526.post@n5.nabble.com>
Permalink:  ../1395116664140-5796526.post@n5.nabble.com/
Also on:    postgresql.org/message-id/1395116664140-5796526.post@n5.nabble.com

 · 

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-bugs@postgresql.org
  Cc: polobo@yahoo.com
  Subject: Re: BUG #9606: pg_class relhaspkey column not updated on removal of primary key
  In-Reply-To: <1395116664140-5796526.post@n5.nabble.com>
  References: <20140317185255.20724.49675@wrigleys.postgresql.org> <25726.1395082770@sss.pgh.pa.us> <7FBC4B95-6AF6-4CFC-A4E2-DE7D9C30AB4B@pgexperts.com> <D0A66CF0-AD34-4647-9C05-1317ECFB97DC@pgexperts.com> <14341.1395105679@sss.pgh.pa.us> <CAHBAh5sd9BK=7qfjTDYBLSAtBh78rtnMSaGFoyfOb2S29FDxoQ@mail.gmail.com> <1395116664140-5796526.post@n5.nabble.com>

* 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