Re: Feedback on getting rid of VACUUM FULL - Mailing list pgsql-hackers

From Hannu Krosing
Subject Re: Feedback on getting rid of VACUUM FULL
Date
Msg-id 1253205089.778.188.camel@hvost1700
Whole thread Raw
In response to Re: Feedback on getting rid of VACUUM FULL  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Feedback on getting rid of VACUUM FULL
Re: Feedback on getting rid of VACUUM FULL
List pgsql-hackers
On Thu, 2009-09-17 at 12:18 -0400, Tom Lane wrote:
> Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
> > Robert Haas wrote:
> >> On Thu, Sep 17, 2009 at 10:21 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >>> Anything that moves tuples is not acceptable as a hidden background
> >>> operation, because it will break applications that depend on CTID.
> 
> >> I'm a bit confused.  CTIDs change all the time anyway, whenever you
> >> update the table.  What could someone possibly be using them for?
> 
> > As a unique identifier, while you hold a portal open.
> 
> Or for an update without having to hold a transaction open.  We have
> recommended this type of technique in the past:
> 
>     select ctid, xmin, * from table where id = something;
> 
>     ... allow user to edit the row at his leisure ...
> 
>     update table set ... where id = something and
>         ctid = previous value and xmin = previous value;
>     if rows_updated = 0 then
>         report error ("row was already updated by someone else");
> 
> (Actually, the ctid is only being used for fast access here; the xmin
> is what is really needed to detect that someone else updated the row.
> But the proposed tuple-mover would break the xmin check too.)

I have used mostly duck-typed, interface-not-identity  languages lately,
so for me the natural thing to check in similar situation is if any
"interesting columns" have changed, by simply preserving old values in
user application and use these in WHERE clause of update.

Why should anyone care if there has been say a null update (set id=id
where id=...) ?

If you need real locking, then just define a locked (or locked_by or
locked_until) column and use that for concurrent edit control

> > It's no different from the situation where another backend UPDATEs the
> > row under your nose, but it's not something you want to do automatically
> > without notice.
> 
> Exactly.  The application is typically going to throw a "concurrent
> update" type of error when this happens, and we don't want magic
> background operations to cause that.

Would'nt current VACUUM FULL or CLUSTER cause much more grief in this
situation ?

-- 
Hannu Krosing   http://www.2ndQuadrant.com
PostgreSQL Scalability and Availability   Services, Consulting and Training




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Feedback on getting rid of VACUUM FULL
Next
From: Robert Haas
Date:
Subject: Re: Feedback on getting rid of VACUUM FULL