Re: [BUGS] Re: Re: [SQL] MAX() of 0 records. - Mailing list pgsql-hackers

From Robert B. Easter
Subject Re: [BUGS] Re: Re: [SQL] MAX() of 0 records.
Date
Msg-id 0007071258480C.01354@comptechnews
Whole thread Raw
In response to Re: [BUGS] Re: Re: [SQL] MAX() of 0 records.  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [BUGS] Re: Re: [SQL] MAX() of 0 records.
List pgsql-hackers
On Fri, 07 Jul 2000, Tom Lane wrote:
> Chris Bitmead <chris@bitmead.com> writes:
>     UPDATE foo
>     SET bar = (SELECT min(f1) FROM othertab
>                WHERE othertab.keycol = foo.keycol)
>     WHERE condition-determining-which-foo-rows-to-update
> if you wanted to use an aggregate.  This is pretty ugly, especially so

If you use min(x) or max(x) frequently, isn't it best to make a trigger that
intercepts x on insert and update, then check it and store it somewhere rather
than scanning for it everytime?  (not that this fixes any db problem thats being
discussed here)
--         Robert


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Re: [SQL] Re: [GENERAL] lztext and compression ratios...
Next
From: Tom Lane
Date:
Subject: Re: Memo on coding practices: strcmp() does not yield bool