Received: from dune.krs.ru (dune.krs.ru [195.161.16.38]) by hub.org (8.9.1/8.9.1) with ESMTP id WAA07302; Tue, 24 Nov 1998 22:26:59 -0500 (EST) (envelope-from vadim@krs.ru) Received: from krs.ru (localhost.krs.ru [127.0.0.1]) by dune.krs.ru (8.8.8/8.8.7) with ESMTP id KAA23896; Wed, 25 Nov 1998 10:26:43 +0700 (KRS) (envelope-from vadim@krs.ru) Sender: root@dune.krs.ru Message-ID: <365B78F2.F5E791D5@krs.ru> Date: Wed, 25 Nov 1998 10:26:42 +0700 From: Vadim Mikheev Organization: OJSC Rostelecom (Krasnoyarsk) X-Mailer: Mozilla 4.5 [en] (X11; I; FreeBSD 2.2.6-RELEASE i386) X-Accept-Language: ru, en MIME-Version: 1.0 To: Jan Wieck CC: s-fery@kkt.sote.hu, pgsql-sql@postgreSQL.org, hackers@postgreSQL.org Subject: Re: [HACKERS] Re: [SQL] cursor and update + view References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Jan Wieck wrote: > > > rule system will be able to put _any_ VIEW' query into > > FROM clause... > > Possible - but IMHO the wrong thing to do. As it is now for a "Will be able" doesn't mean "will DO" -:)) I just said that subqueries in FROM will resolve all problems with aggregates in VIEWs. > If we put any view into a subquery RTE, we force the planner > to materialize the view and do a nestloop over t3 and ^^^^^^^^^^^ Do you mean creating some tmp table etc? No - it's not required. > materialized v1 where possibly using t1 or t2 as the > outermost scanrelation would be better. SELECT t3.a, v1.b, v1.c FROM t3, (SELECT t1.a, t1.b, t2.c FROM t1, t2 WHERE t1.a = t2.a) v1 WHERE t3.a = v1.a; can be planned as Nestloop SubPlan ...what is costless for subquery... Seq/Index scan on t3 - no materialization... On the other hand, as we talk about query optimization - why rule system should do optimizer' work? Why not just put _any_ VIEW' query into FROM and let optimizer decide could query be rewritten as join or not? Ppl do strange things sometimes -:) Sometimes they use subqueries in WHERE while joins could be used and our optimizer don't try to catch this. I know that Sybase does. And, imho, we should implement this ... sometime -:)) Vadim