X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.225.181]) by svr1.postgresql.org (Postfix) with ESMTP id AEB7DD1C4C7 for ; Mon, 21 Jul 2003 15:24:14 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr5.postgresql.org [64.117.225.181]) (amavisd-new, port 10024) with ESMTP id 38455-01 for ; Mon, 21 Jul 2003 15:24:03 +0000 (GMT) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by svr1.postgresql.org (Postfix) with ESMTP id 3FECAD1C913 for ; Mon, 21 Jul 2003 12:24:02 -0300 (ADT) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id h6LFNa112572; Mon, 21 Jul 2003 11:23:36 -0400 (EDT) From: Bruce Momjian Message-Id: <200307211523.h6LFNa112572@candle.pha.pa.us> Subject: Re: avoid select expens_expr(col) like unneccessary calculations In-Reply-To: <20030707154329.J82767-100000@megazone23.bigpanda.com> To: Stephan Szabo Date: Mon, 21 Jul 2003 11:23:36 -0400 (EDT) Cc: Markus Bertheau , pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/308 X-Sequence-Number: 14422 Stephan Szabo wrote: > On 8 Jul 2003, Markus Bertheau wrote: > > > when you have > > select expensive_expression(column), * from table offset 20 limit 40 > > > > can you somehow save the cost for the first 20 calculations of > > expensive_expression? > > Right now the only way I can think of that might work is to push the > offset/limit into a subselect on table and then do the > expensive_expression at the top level. Well, you can do: SELECT * FROM (SELECT * FROM pg_class) AS pg_class so you could do: SELECT func(relname), * FROM (SELECT * FROM pg_class OFFSET 20 LIMIT 40) AS pg_class -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073