Re: Add primary key/unique constraint using prefix columns of an index

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add primary key/unique constraint using prefix columns of an index
Date: 2012-05-23 17:13:22
Message-ID: CA+TgmoZ4o8aJOtgNhmsaiS9aKM7k5Uj6dxw3DGk74o9cKh5WVA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, May 22, 2012 at 5:26 PM, Simon Riggs <simon(at)2ndquadrant(dot)com> wrote:
>>  A bigger problem is that creating such an index turns all
>> of pgbench's write traffic from HOT updates into non-HOT updates,
>> which means this is probably only going to be a win if the write
>> volume is miniscule.
>
> Not sure whether you see that as an argument against the proposal.
> This argument applies to any index. In particular covered indexes are
> specifically encouraged by index only scans, so is not a reason to
> avoid implementing the feature as Jeff describes.

I don't object to the feature, but I think it's real-world utility
will be more limited than we might hope. When covering indexes are
not in play, someone might choose to index only, say, the primary key.
And maybe the primary key doesn't change very often, so HOT still
applies to nearly all updates. But then when they try to make a
covering index, they're now indexing columns that they *do* update
pretty regularly. Now the gain from index-only scans is fighting with
the loss from some updates no longer being HOT. I think in many cases
losing the benefit of HOT will cost more than the covering index
gains, at least in 9.2. I hope we'll be able to improve it in future
releases.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-05-23 17:23:43 Re: Add primary key/unique constraint using prefix columns of an index
Previous Message Fujii Masao 2012-05-23 17:10:55 Re: Archiver not exiting upon crash