> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
>
> "Hiroshi Inoue" <Inoue@tpf.co.jp> writes:
> >>>> I know another case. pg_attrdef has no index on (adrelid,attnum)
> >>>> though it has an index on (adrelid).
> >>
> >> Doesn't look to me like we need an index on (adrelid,attnum), at
> >> least not in any paths that are common enough to justify maintaining
> >> another index. The (adrelid) index supports loading attrdef data
> >> into the relcache, which is the only path I'm particularly concerned
> >> about performance of...
>
> > It seems to me that an index on (adrelid,adnum) should
> > exist instead of the current index. It identifies pg_attrdef.
> > I say *Oops* about it in my trial implementation of ALTER
> > TABLE DROP COLUMN.
>
> Right, I saw that. But it seems to be the only place where such an
> index would be useful. The relcache-loading routines, which seem to
> be the only performance-critical access to pg_attrdef, prefer an index
> on adrelid only. Is it worth maintaining a 2-column index (which is
> bulkier and slower than a 1-column one) just to speed up ALTER TABLE
> DROP COLUMN?
>
I don't mind so much about the performance in this case.
The difference would be little.
Isn't it a fundamental principle to define primary(unique
identification) constraint for each table ?
I had never thought that the only one index of pg_attrdef
isn't an unique identification index until I came across the
unexpcted result of my DROP COLUMN test case.
Comments ?
Regards.
Hiroshi Inoue
Inoue@tpf.co.jp