Re: SELECT * FROM <table> LIMIT 1; is really slow

From: Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, David Blasby <dblasby(at)refractions(dot)net>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: SELECT * FROM <table> LIMIT 1; is really slow
Date: 2004-05-27 06:13:23
Message-ID: Pine.LNX.4.44.0405270810520.24368-100000@zigo.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 26 May 2004, Tom Lane wrote:

> if you have to do an UPDATE that affects every row of a large table
>
> UPDATE tab SET col = col + 1
>
> which leaves you with N live rows, N dead rows, and lots of pain to get
> back down to a less-than-twice-normal-size table. (Traditional way is
> VACUUM FULL; CLUSTER is better, but still painful.) As of 7.5 you could
> hack this with
>
> ALTER TABLE tab ALTER COLUMN col TYPE same-type USING col + 1
>
> which will have the effect of rewriting a fresh table file containing
> the updated rows, and dropping the old file at commit.
>
> I'm not real sure where to document this
> trick but it seems like we ought to mention it someplace.

Isn't it better to detect a UPDATE without a where and do that update in
the same way as the alter table above? Then we don't need to document and
learn a new non standard way of doing an update.

--
/Dennis Björklund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephan Szabo 2004-05-27 06:23:58 Re: Nested xacts: looking for testers and review
Previous Message Alvaro Herrera 2004-05-27 05:11:10 Re: Nested xacts: looking for testers and review