Received: from comptechnews.com (root@cc993546-b.srst1.fl.home.com [24.3.77.52]) by hub.org (8.10.1/8.10.1) with ESMTP id e67GvIW81226; Fri, 7 Jul 2000 12:57:18 -0400 (EDT) Received: from comptechnews (reaster@localhost [127.0.0.1]) by comptechnews.com (8.9.3/8.9.3) with SMTP id MAA02992; Fri, 7 Jul 2000 12:58:48 -0400 From: "Robert B. Easter" To: Tom Lane , Chris Bitmead Subject: Re: Re: [HACKERS] Re: [SQL] MAX() of 0 records. Date: Fri, 7 Jul 2000 12:53:27 -0400 X-Mailer: KMail [version 1.0.28] Content-Type: text/plain Cc: pgsql-bugs@postgresql.org, pgsql-hackers@postgresql.org References: <396535EF.8132CF80@opentec.com.au> <3965F8A6.3322C001@bitmead.com> <10551.962987714@sss.pgh.pa.us> In-Reply-To: <10551.962987714@sss.pgh.pa.us> MIME-Version: 1.0 Message-Id: <0007071258480C.01354@comptechnews> Content-Transfer-Encoding: 8bit X-Archive-Number: 200007/52 On Fri, 07 Jul 2000, Tom Lane wrote: > Chris Bitmead 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